雖然以前已經學了2個月python,但仍然感受學的很亂,沒有系統性;或者說自學的沒有條例,只是追求進度,沒有保證知識點的全面與準確。python
從今天開始,從python的基礎變量開始從新整理知識點,梳理忽略的內容。願所學即所會,所會即能用。編程
一、變量名遵循的規則app
二、變量名錯誤常見錯誤提示:函數
轉引《python:從入門到實踐》中的附錄code
Python關鍵字和內置函數orm
4 Python關鍵字和內置函數 Python包含一系列關鍵字和內置函數,給變量命名時,知道這些關鍵字和內置函數很重要。編程中面臨的一個挑戰是給變量指定合適的名稱,變量名能夠是任何東西,只要它長短 合適並描述了變量的做用。同時,不能將Python關鍵字用做變量名;也不該將Python內置函數的名稱用做變量名,不然將覆蓋相應的內置函數。 本節將列出Python關鍵字和內置函數的名稱,讓你知道應避免使用哪些變量名。ip
4.1 Python關鍵字 下面的關鍵字都有特殊含義,若是你將它們用做變量名,將引起錯誤:unicode
False | class | finally | is | return |
None | continue | for | lambda | try |
True | def | from | nonlocal | while |
and | del | global | not | with |
as | elif | if | or | yield |
assert | else | import | pass | |
break | expect | in | raise |
4.2 Python內置函數 將內置函數名用做變量名時,不會致使錯誤,但將覆蓋這些函數的行爲:get
abs() | divmod() | input() | open() | staticmethod() |
all() | enumerate() | int() | ord() | str() |
any() | eval() | isinstance() | pow() | sum() |
basestring() | execfile() | issubclass() | print() | super() |
bin() | file() | iter() | property() | tuple() |
bytearray() | filter() | len() | range() | type() |
callable() | float() | list() | raw_input() | unichr() |
chr() | format() | locals() | reduce() | unicode() |
classmethod() | frozenset | long() | reload() | vars() |
cmp() | getattr() | map() | repr() | xrange() |
compile() | globals() | max() | reversed()zip() | Zip() |
complex() | hasattr() | next() | round() | _import_() |
delattr() | hash() | object() | set() | apply() |
dict() | help() | memoryview() | setattr() | buffer() |
dir() | hex() | min() | slice() | coerce() |
bool() | id() | oct() | sorted() | intern() |