首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Python 学习(六)

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.

  • 发表于:
  • 原文链接https://kuaibao.qq.com/s/20180626G204PP00?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券