python之禪
-
操作
1.在 jupyter中輸入import this
-
內(nèi)容及解釋:
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
優(yōu)美勝于丑陋
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.
即便假借特例的實用性之名,也不可違背這些規(guī)則(這些規(guī)則至高無上)
Errors should never pass silently.
Unless explicitly silenced.
不要包容所有錯誤,除非你確定需要這樣做(精準地捕獲異常,不寫except:pass風格的代碼)
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.
雖然這并不容易贾费,因為你不是 Python 之父(這里的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環(huán)境
1.在Python官方網(wǎng)站下載對應版本的python安裝程序(exe文件)沟涨,安裝時建議勾選“Add Python 3.6 to PATH”(將Python 3.6添加到PATH環(huán)境變量),并且將“pip”异吻、“tcl/tk”裹赴、“Python test suite”等項全部勾選上。
注意:在Windows 7環(huán)境下安裝時诀浪,需要先安裝Service Pack 1補丁包(可以通過一些工具軟件自動安裝系統(tǒng)補丁的功能來安裝)
從終端運行Python
打開命令提示符:win+r >> cmd
-
確認python版本
方法一:
python --version
方法二:
import sys
print(sys.version_info)
print(sys.version)
-
運行python程序
python hello.py
jupyter
-
安裝環(huán)境
1.win+r >> cmd
2.python _m pip install ipython jupyter
-
使用jupyter
1.win+r >> cmd
2.jupyter notebook
PyCharm
1.首先要有java運行環(huán)境棋返,這個環(huán)境要安裝在C盤
2.在PyCharm官方網(wǎng)站下載安裝包,安裝時勾選64-bit雷猪,Do not import…
3.激活:需要激活碼睛竣,lanyu提供免費激活碼彩倚,但PyCharm每次會自動驗證注冊碼铐望,而注冊碼是動態(tài)的,那么用戶每次使用時恨憎,都需要重新生成激活碼与境,為了用戶使用方便验夯,我們可自行屏蔽驗證注冊碼的網(wǎng)站,方法如下:
a.找到hosts文件摔刁,路徑:C:\windows\system32\drivers\etc
b.在hosts文件中加入 代碼:0.0.0.0 account.jetbrains.com