Python 3.x 保留字列表 (33个)
and | elif | import | raise |
as | else | in | return |
assert | except | is | try |
break | finally | lambda | while |
class | for | nonlocal | with |
continue | from | not | yield |
def | global | or | TRUE |
del | if | pass | FALSE |
None |
使用变量前必须赋值,否则编译器报错
空格不能将命名分割
空格增加程序的可读性
字符串可以理解为字节序列,若长度为L,第一个字节索引 为 0 或者 -L ,最后一个字节的索引 为 L-1 或者 -1。
val[0:-1]来获取除了最后一个字符串外的字符串
同步赋值语句:同时给多个变量赋值(先运算右侧N个表达式,最后同事讲表达式结果赋给左侧)
<val1>,...,<valN>=<Expression1>,...,<ExpressionN>
t=x,x=y,y=t ---->>>> x,y=y,x
循环语句
计数循环
for i in range(val):
<Expression>
input - print 模板
input()
arithmetic()
print()
initial-print 模板
init val()
arithmetic()
printf()