File tree Expand file tree Collapse file tree 10 files changed +98
-17
lines changed Expand file tree Collapse file tree 10 files changed +98
-17
lines changed Original file line number Diff line number Diff line change 1
1
# 前言 #
2
2
3
- Python 学习之旅,先来看看 Python 的代码规范,让自己先有个意识,而且在往后的学习中慢慢养成习惯
3
+ 本来不应该把这个章节放在那面前面的,因为还没进行学习之前,直接看这个章节,会感觉有很多莫名其妙的东西。
4
+
5
+ 但是把这个章节放在前面的用意,只是让大家预览一下,有个印象,而且在以后的学习中,也方便大家查阅。
4
6
5
7
# 目录 #
6
8
7
- ![ Python代码规范] ( https://dn-mhke0kuv.qbox.me/a542abfa2efe1fefd95e.png )
9
+ ![ ] ( http://twowaterimage.oss-cn-beijing.aliyuncs.com/2019-07-20-Python%E4%BB%A3%E7%A0%81%E8%A7%84%E8%8C%83.png )
10
+
Original file line number Diff line number Diff line change 4
4
5
5
### 1.1、块注释
6
6
“#”号后空一格,段落件用空行分开(同样需要“#”号)
7
+
7
8
``` python
8
9
# 块注释
9
10
# 块注释
14
15
15
16
### 1.2、行注释
16
17
至少使用两个空格和语句分开,注意不要使用无意义的注释
18
+
17
19
``` python
18
20
# 正确的写法
19
21
x = x + 1 # 边框加粗一个像素
@@ -122,3 +124,5 @@ def func(arg1, arg2):
122
124
* 文档注释不是越长越好, 通常一两句话能把情况说清楚即可
123
125
124
126
* 模块、公有类、公有方法, 能写文档注释的, 应该尽量写文档注释
127
+
128
+
File renamed without changes.
Original file line number Diff line number Diff line change 1
1
# 四、集成开发环境(IDE): PyCharm #
2
2
3
- 当然,在学习周期还是建议使用文本编辑器或者是[ Sublime Text] ( http://www.sublimetext.com/ ) 这个工具来操作的,因为这样有利于我们了解整个流程,到一定的程度,或者开始项目的时候就可以使用集成的开发环境了,这样可以提高我们的效率。PyCharm 是由 JetBrains 打造的一款 Python IDE,支持 macOS、 Windows、 Linux 系统。
3
+ 我本人一直是建议在学习周期使用文本编辑器或者是[ Sublime Text] ( http://www.sublimetext.com/ ) 这个工具来写 Python 程序的,因为这样有利于我们了解整个流程。
4
+
5
+ 当然,如果你有一定的编程基础,是可以使用集成的开发环境的,这样可以提高效率。这时,你可以选择 PyCharm ,PyCharm 是由 JetBrains 打造的一款 Python IDE,支持 macOS、 Windows、 Linux 系统。
4
6
5
7
PyCharm 下载地址 : [ https://www.jetbrains.com/pycharm/download/ ] ( https://www.jetbrains.com/pycharm/download/ )
8
+
9
+
Original file line number Diff line number Diff line change 2
2
3
3
因为 Python 是跨平台的,它可以运行在 Windows、Mac 和各种 Linux/Unix 系统上。目前,Python 有两个版本,一个是 2.x 版,一个是 3.x版,这两个版本是不兼容的。本草根安装的是 3.6.1 版本的。
4
4
5
- 至于在哪里下载,本草根建议最好直接官网下载啦 ,随时下载下来的都是最新版本。官网地址:[ https://www.python.org/ ] ( https://www.python.org/ )
5
+ 至于在哪里下载,草根我建议大家最好直接官网下载 ,随时下载下来的都是最新版本。官网地址:[ https://www.python.org/ ] ( https://www.python.org/ )
6
6
7
- 本草根是 windows 系统,下载完后,直接安装,不过这里记得勾上Add Python 3.6 to PATH,然后点 “Install Now” 即可完成安装。如果没有勾上这个,就必须要自己配置环境变量了,至于如何配置,跟 JAVA 的差不多,具体可以 Google 一下。
7
+ ## 1、windows 系统下安装配置 ##
8
+
9
+ 如果是 windows 系统,下载完后,直接安装,不过这里记得勾上Add Python 3.6 to PATH,然后点 「Install Now」 即可完成安装。
10
+
11
+ 这里要注意了,记得把「Add Python 3.6 to Path」勾上,勾上之后就不需要自己配置环境变量了,如果没勾上,就要自己手动配置。
8
12
9
13
![ Python安装.png] ( http://upload-images.jianshu.io/upload_images/2136918-2bf6591f0a12e80b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240 )
10
14
11
- 安装完成后,打开命令提示符窗口,敲入 python 后,出现下面的情况,证明 Python 安装成功了。你看到提示符 >>> 就表示我们已经在 Python交互式环境中了,可以输入任何 Python 代码,回车后会立刻得到执行结果。
15
+ 如果你一时手快,忘记了勾上 「Add Python 3.6 to Path」,那也不要紧,只需要手动配置一下环境变量就好了。
16
+
17
+ 在命令提示框中 cmd 上输入 :
18
+
19
+ ```
20
+ path=%path%;C:\Python
21
+ ```
22
+
23
+ 特别特别注意: ` C:\Python ` 是 Python 的安装目录,如果你的安装目录是其他地方,就得填上你对应的目录。
24
+
25
+ 安装完成后,打开命令提示符窗口,敲入 python 后,出现下面的情况,证明 Python 安装成功了。
26
+
27
+ ![ 运行python.png] ( http://upload-images.jianshu.io/upload_images/2136918-817c22f802e8cfce.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240 )
28
+
29
+ 而你看到提示符 ` >>> ` 就表示我们已经在 Python 交互式环境中了,可以输入任何 Python 代码,回车后会立刻得到执行结果。
30
+
31
+
32
+ ## 2、Mac 系统下安装配置 ##
33
+
34
+ MAC 系统一般都自带有 Python2.x 版本的环境,不过现在都不用 2.x 的版本了,所以建议你在 https://www.python.org/downloads/mac-osx/ 上下载最新版安装。
35
+
36
+ 安装完成之后,如何配置环境变量呢?
37
+
38
+ 先查看当前环境变量:
39
+
40
+ ```
41
+ echo $PATH
42
+ ```
43
+
44
+ 然后打开 ``` ~/.bash_profile(没有请新建) ```
45
+
46
+ ```
47
+ vi ~/.bash_profile
48
+ ```
49
+
50
+ 我装的是 Python3.7 ,Python 执行路径为:` /Library/Frameworks/Python. Framework/Versions/3.7/bin ` 。于是写入
51
+
52
+ ```
53
+ export PATH="/Library/Frameworks/Python. Framework/Versions/3.7/bin:$PATH"
54
+ ```
55
+
56
+ ![ ] ( http://twowaterimage.oss-cn-beijing.aliyuncs.com/2019-07-22-084149.png )
57
+
58
+ 最后保存退出,激活运行一下文件:
59
+
60
+ ```
61
+ source ~/.bash_profile
62
+ ```
63
+
64
+
65
+
66
+
67
+
12
68
13
- ![ 运行python.png] ( http://upload-images.jianshu.io/upload_images/2136918-817c22f802e8cfce.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240 )
Original file line number Diff line number Diff line change @@ -6,11 +6,11 @@ Python 是著名的“龟叔” Guido van Rossum 在 1989 年圣诞节期间,
6
6
7
7
这是 2017 年 2 月编程语言排行榜 TOP20 榜单:
8
8
9
- ![ 2 月编程语言排行榜 TOP20 榜单.png] ( http://upload-images.jianshu.io/upload_images/2136918-f7fc786f001cbfc0?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240 )
9
+ ![ 2 月编程语言排行榜 TOP20 榜单.png] ( http://twowaterimage.oss-cn-beijing.aliyuncs.com/2019-07-22-080118.jpg )
10
10
11
11
还有就是 Top 10 编程语言 TIOBE 指数走势:
12
12
13
- ![ Top 10 编程语言 TIOBE 指数走势.png ] ( http://upload-images.jianshu.io/upload_images/2136918-2714dba010ea5d75.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240 )
13
+ ![ ] ( http://twowaterimage.oss-cn-beijing.aliyuncs.com/2019-07-22-080145.jpg )
14
14
15
15
总的来说,这几种编程语言各有千秋,但不难看出,最近几年 Python 的发展非常的快,特别最近流行的机器学习,数据分析,更让 python 快速的发展起来。
16
16
@@ -21,3 +21,5 @@ Python 是高级编程语言,它有一个特点就是能快速的开发。Pyth
21
21
第一个缺点就是运行速度慢,和C程序相比非常慢,因为Python是解释型语言,你的代码在执行时会一行一行地翻译成CPU能理解的机器码,这个翻译过程非常耗时,所以很慢。而C程序是运行前直接编译成CPU能执行的机器码,所以非常快。
22
22
23
23
第二个缺点就是代码不能加密。如果要发布你的 Python 程序,实际上就是发布源代码。像 JAVA , C 这些编译型的语言,都没有这个问题,而解释型的语言,则必须把源码发布出去。
24
+
25
+
Original file line number Diff line number Diff line change 1
1
# 前言 #
2
2
3
- 一时冲动,就开始把 Python 的知识点做个总结归纳了。 [ gitbook ] ( https://www.readwithu.com/ ) 同时更新 。
3
+ 每个编程语言的学习,第一个程序都是先向世界问好,Python 也不例外,这节我们先写下第一个 Python 程序 —— Hello World 。
4
4
5
5
# 目录 #
6
6
7
- ![ 草根学 Python(一) 第一个 Python 程序] ( https://dn-mhke0kuv.qbox.me/2903b288b72a7ddb730c.png )
7
+ ![ ] ( http://twowaterimage.oss-cn-beijing.aliyuncs.com/2019-07-22-%E8%8D%89%E6%A0%B9%E5%AD%A6%20Python%EF%BC%88%E4%B8%80%EF%BC%89%20%E7%AC%AC%E4%B8%80%E4%B8%AA%20Python%20%E7%A8%8B%E5%BA%8F.png )
8
+
Original file line number Diff line number Diff line change 1
1
# 三、第一个 Python 程序 #
2
2
3
- Python 的代码使用文本编辑器就可以写了,本草根使用 [ Sublime Text] ( http://www.sublimetext.com/ ) ,第一个 Python 程序当然是 Hello Python 啦,把这句话打印出来。
3
+ 好了,说了那么多,现在我们可以来写一下第一个 Python 程序了。
4
+
5
+ 一开始写 Python 程序,个人不太建议用专门的工具来写,不方便熟悉语法,所以这里我先用 [ Sublime Text] ( http://www.sublimetext.com/ ) 来写,后期可以改为用 PyCharm 。
6
+
7
+ 第一个 Python 程序当然是打印 Hello Python 啦。
8
+
9
+ 如果你没编程经验,什么都不懂,没关系,第一个 Python 程序,只要跟着做,留下个印象,尝试一下就好。
10
+
11
+ 新建一个文件,命名为 ` HelloPython.py ` , 注意,这里是以 ` .py ` 为后缀的文件。
12
+
13
+ 然后打开文件,输入 ` print('Hello Python') `
4
14
5
- 注意 print 前面不要有任何空格,最后保存下来,可以看到,Python 保存后是一个以 .py 为后缀的文件。
6
15
7
16
![ HelloPython.png] ( http://upload-images.jianshu.io/upload_images/2136918-f0ec1b2c06d1ab18.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240 )
8
17
@@ -15,4 +24,5 @@ Python 的代码使用文本编辑器就可以写了,本草根使用 [Sublime
15
24
16
25
当然,如果你是使用 [ Sublime Text] ( http://www.sublimetext.com/ ) ,并且在安装 Python 的时候配置好了环境变量,直接按 Ctrl + B 就可以运行了,运行结果如下:
17
26
18
- ![ Sublime运行Python.png] ( http://upload-images.jianshu.io/upload_images/2136918-a771a2fa1e4c03bd.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240 )
27
+ ![ Sublime运行Python.png] ( http://upload-images.jianshu.io/upload_images/2136918-a771a2fa1e4c03bd.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240 )
28
+
Original file line number Diff line number Diff line change @@ -24,11 +24,13 @@ IT 行业相对于一般传统行业,发展更新速度更快,一旦停止
24
24
25
25
对于入门,主要是掌握基本的语法和熟悉编程规范,因此大部分的教程基本一致的,所以还是建议选好适合自己的一个教程,坚持学下去。
26
26
27
- 在 Python 入门中,本人编写了一系列的 《草根学 Python 》 博客, 是基于 Python 3.6 写的 Python 入门系列教程,为了更好的阅读,把它整理在 [ GitBook] ( https://www.readwithu.com/ ) 上;如果 [ GitBook] ( https://www.readwithu.com/ ) 访问慢,也可以到个人博客查阅:[ 草根学 Python] ( http://twowater.com.cn/categories/Python/%E8%8D%89%E6%A0%B9%E5%AD%A6-Python/ ) ,希望对各位入门 Python 有所帮助。
27
+ 在 Python 入门中,本人编写了一系列的 《草根学 Python 》 博客, 是基于 Python 3.6 写的 Python 入门系列教程,为了更好的阅读,把它整理在 [ GitBook] ( https://www.readwithu.com/ ) 上,希望对各位入门 Python 有所帮助。
28
+
29
+ > 注:2018 年 02 月 27 日,基础知识入门部分已经完成了的。因近期读者反映有些图片没法打开了(之前图片放在七牛云,用的是临时链接,最近七牛云把这个给关闭了,导致图片没法打开),且自己对之前的内容有些不满意,决定在 2019 年 7 月 7 日开始进行了再次修改。
28
30
29
31
** 主要目录如下:**
30
32
31
- * [ 为什么学Python?] ( /Article/python0/为什么学Python? .md )
33
+ * [ 为什么学Python?] ( /Article/python0/WhyStudyPython .md )
32
34
* [ Python代码规范] ( /Article/codeSpecification/codeSpecification_Preface.md )
33
35
- [ 简明概述] ( /Article/codeSpecification/codeSpecification_first.md )
34
36
- [ 注释] ( /Article/codeSpecification/codeSpecification_second.md )
Original file line number Diff line number Diff line change 1
1
# Summary
2
2
3
3
* [ 前言] ( README.md )
4
- * [ 为什么学Python?] ( /Article/python0/为什么学Python ?.md )
4
+ * [ 为什么学Python?] ( /Article/python0/WhyStudyPython ?.md )
5
5
* [ Python代码规范] ( /Article/codeSpecification/codeSpecification_Preface.md )
6
6
- [ 简明概述] ( /Article/codeSpecification/codeSpecification_first.md )
7
7
- [ 注释] ( /Article/codeSpecification/codeSpecification_second.md )
You can’t perform that action at this time.
0 commit comments