Assignment Statements
Assignments create object references.
Names are created when first assigned.
Names nust be assigned before being referenced.
Some operations perform assignments implicitly.
Augmented Assignments 增量赋值
Augmented assignment and shared reference.
+=really means extend
变量命名规则
Variable Name Rules
Syntax:(underscore or lette)+(any number of letters,digits,or underscores)
Variable names must start with an underscore or letter,which can be followed by any
number of letters ,digits,or underscores.
Case matters:
Reserved words are off-lim its
print 函数正则表达式:
print([object,...][,sep=''][,end='\n'][,file=sys.stdout])
If you assing them this way:
A=B=C=[]
all three names reference the same object,so changing it in-place from one
(e.g.,A.append(99))will affect the others .This is true only for in-place changes to
mutable objects like lists and dictionaries; for immutable objects such as numbers
and strings,this issue is irrelevant.
领取专属 10元无门槛券
私享最新 技术干货