學習一門熱門語言
計算機語言都是從helloworld開始
mac或linux
下自帶python,windows需要安裝,具體安裝步驟問度娘。
建立python
指令碼如下,vim helloword.py
#!/usr/bin/python
#coding=utf-8
#剽悍的代
碼不需要解析
#解析也沒用
就那麼幾行沒人看
'hello python!'
print'在
這個世界
小小python'
'you can\'t imagine how powerful you are!'
然後執行pythonhelloworld.py
注意:
在mac下安裝pylint可能遇到點問題,
/usr/bin/python: nomodule named pip
解決方法是安裝pip,
sudo easy_install pip
這樣就可以安裝pylint了
安裝過程又出現
collecting pylint
using cachedpylint-1.7.1-py2.py3-none-any.whl
collecting astroid>=1.5.1 (from pylint)
using cachedastroid-1.5.3-py2.py3-none-any.whl
collecting singledispatch; python_version <"3.4" (from pylint)
using cachedsingledispatch-3.4.0.3-py2.py3-none-any.whl
collecting mccabe (from pylint)
using cachedmccabe-0.6.1-py2.py3-none-any.whl
collecting backports.functools-lru-cache;python_version == "2.7" (from pylint)
using cachedbackports.functools_lru_cache-1.4-py2.py3-none-any.whl
requirement alreadysatisfied: six in/system/library/frameworks/python.framework/versions/2.7/extra
s/lib/python(from pylint)
collecting isort>=4.2.5 (from pylint)
using cached isort-4.2.15-py2.py3-none-any.whl
collecting configparser; python_version =="2.7" (from pylint)
using cached configparser-3.5.0.tar.gz
collecting enum34>=1.1.3; python_version <"3.4" (from astroid>=1.5.1->pylint)
using cachedenum34-1.1.6-py2-none-any.whl
collecting lazy-object-proxy (fromastroid>=1.5.1->pylint)
using cachedlazy-object-proxy-1.3.1.tar.gz
collecting wrapt (fromastroid>=1.5.1->pylint)
using cached wrapt-1.10.10.tar.gz
installing collected packages: enum34,singledispatch, lazy-object-proxy, backports.functools-lru-ca
che, wrapt, astroid, mccabe, isort,configparser, pylint
exception:
raceback(most recent call last):
file"/library/python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py",line 215, in main
status = self.run(options, args)
file"/library/python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py",line 342, in
runprefix=options.prefix_path,
file"/library/python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py",line 784, in inst
all**kwargs
file"/library/python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py",line 851, in
install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
file"/library/python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py",line 1064, in
move_wheel_files
isolated=self.isolated,
file"/library/python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py",line 345, in move_wheel
_files
clobber(source, lib_dir, true)
file "/library/python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py",line 316, in clobber
ensure_dir(destdir)
file"/library/python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py",line 83, in en
sure_dir
os.makedirs(path)
file "/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/os.py",line 157, in
makedirs
mkdir(name, mode)
oserror: [errno 13] permission denied: '/library/python/2.7/site-packages/enum'
這個應該是許可權錯誤。
沒辦法乙個個建立資料夾,比如在/library/python/2.7/site-packages/下執行
sudo mkdir enum
後面的許可權報錯一樣的處理方法,一步步試驗,直到安裝成功
其實不用這麼麻煩
sudo /usr/bin/python -mpip install pylint
就可以了
Python修煉之路 異常
在程式出現bug時一般不會將錯誤資訊直接顯示給使用者,而是可以自定義顯示內容或處理。常見異常 attributeerror 試圖訪問乙個物件沒有的樹形,比如foo.x,但是foo沒有屬性x ioerror 輸入 輸出異常 基本上是無法開啟檔案 importerror 無法引入模組或包 基本上是路徑問...
自學python計畫 python學習計畫
文件 為 從網路收集整理 word 版本可編輯 python 學習計畫 篇一 python 學習計畫 篇一 python 之模組學習 python 之模組學習 模組簡介 python 是由一系列的模組組成的,每個模組就是乙個 py為字尾的檔案,同時模組也是乙個命名空間,從而避免了 變數名稱衝突的問題...
Python從0到1 常用基本操作
其他常用操作見 次方 print 次方 print 2 3 變數型別 print 變數型別 tang 123 print type tang 型別轉換 print 型別轉換 tang 123 print str tang print float tang bool型別 false true 首字母大...