python入门:工欲善其事,必先利其器

未来将是一个全民编程的年代。本头条号以科普为基础,旨在向大家介绍如何快速掌握这门编程语言,从而能为自己的工作和生活带来高效和便利。本期的主题是python入门,希望通过下面三个步骤把大家带到python的世界中来。

  1. python安装

  2. IDE的选择

  3. 小试牛刀(爬虫的Hello World)

  4. python的安装

进群:700341555获取各类Python学习资料!

直接从python的官网(https://www.python.org/downloads/)下载就可以,目前最新版本是3.6。

《python入门:工欲善其事,必先利其器》 python入门:工欲善其事,必先利其器

python的下载网址

2.IDE的选择

推荐PyCharm,有免费版。专业版的话需要收费,但是在中国的话你懂的,不赘述。

下载网址是https://www.jetbrains.com/zh/pycharm/specials/pycharm/pycharm.html

全球各地的公司都在使用这个工具,选择这个不会错的。

《python入门:工欲善其事,必先利其器》 python入门:工欲善其事,必先利其器

python的使用厂商

下面介绍一下用pycharm安装Python第三方库的方法,简单暴力!

2.1打开pycharm,点击File,再点击settings

《python入门:工欲善其事,必先利其器》 python入门:工欲善其事,必先利其器

2.2.点击settings之后再点击project下面的project Interpreter将会出现如下界面:

《python入门:工欲善其事,必先利其器》 python入门:工欲善其事,必先利其器

2.3接下来点击上面界面右上角的“+”将会出现如下界面:然后在搜索框中搜索需要安装的第三方库(此处搜索requests)然后点击界面左下角的Install Package进行安装即可。

《python入门:工欲善其事,必先利其器》 python入门:工欲善其事,必先利其器

3.小试牛刀

通过python访问简书(http://www.jianshu.com/),并打印返回源文件。

<pre style=”-webkit-tap-highlight-color: transparent; box-sizing: border-box; font-family: Consolas, Menlo, Courier, monospace; font-size: 16px; white-space: pre-wrap; position: relative; line-height: 1.5; color: rgb(153, 153, 153); margin: 1em 0px; padding: 12px 10px; background: rgb(244, 245, 246); border: 1px solid rgb(232, 232, 232); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;”>from urllib import request
import chardet
response = request.urlopen(“http://www.jianshu.com/“)
html = response.read()
charset = chardet.detect(html)
print(charset)
html = html.decode(str(charset[“encoding”]))
print(html)</pre>

《python入门:工欲善其事,必先利其器》 python入门:工欲善其事,必先利其器

    原文作者:浪里小白龙q
    原文地址: https://www.jianshu.com/p/0a349bc48d8c
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞