# Learn Python with Steem #01 笔记#
[toc]
划重点#
安装Python 在官网下载Python 3.6,由于Python 3.7是最近推出的,可能一些第三方的库还没跟上它的脚步,还不支持Python3.7。
安装的时候要添加到PATH环境变量,这样不管你在哪里使用Pytho电脑都找到得到Python啦。
安装Sublime
Sublime 不仅仅可以用来编程序,还可以编辑其他文本文件,是把利器。
编写第一个程序
万事开头难,但Python的开始学习曲线较平缓,开头不难,要坚持。
编程练习#
1
2
3
4
| # 语言是用来交流的工具,用Python打个招呼。
print('Hello Steemians with Python!')
|
1
| Hello Steemians with Python!
|
1
| print('Follow @deanliu & @antonsteemit, and learn Python with Steem!')
|
1
| Follow @deanliu & @antonsteemit, and learn Python with Steem!
|
1
2
3
| # 看看神奇的Python之禅
import this
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
|
补充(笔记本)#
好高兴,今天的Python课程学完了。
但要是课后的玩耍的时候玩过头了,把今天学的知识忘了怎么办?
嗯,好学生都有会记笔记啦,忘了就翻翻笔记。
我准备了个笔记本,叫 jupyter notebook,就用它记录每天学到的Python知识。
看看这个笔记本长什么样吧:
- 运行在浏览器里,和我们打开的网页一样:
可以用markdown语法记笔记,还可以直接在笔记本上运行Python程序
那如何安装这个笔记本呢?
步骤如下:
python -m pip install jupyter
如果出错,尝试这条命令
pip install jupyter
这样就安装好了。
那如何使用这个笔记本呢?
jupyter notebook
然后会生成这么个网址,一般会自动在浏览器里打开,如果没有,可以自己手动复制粘贴到浏览器里打开
在右上角new菜单选择Python 3:
打开的笔记本:
输入markdown
按Shift + Enter(回车)或者 Ctrl + Enter(回车)执行
输入Python代码
按Shift + Enter(回车)或者 Ctrl + Enter(回车)执行
可以导出多种格式。
这篇文章是在这个笔记本里写的,导出为markdown文件,复制到steemit上发表,感觉如何?赶紧把Python玩起来吧!