显示连接(Explicit line joining)
使用 ‘\’将两行代码为一行:
if 1900 < year < 2100 and 1 <= month <= 12 \
and 1 <= day <= 31 and 0 <= hour < 24 \
and 0 <= minute < 60 and 0 <= second < 60: # Looks ike a valid date
return 1
‘\’ 后不能接注释,不能用于拆分字符串
隐式连接(Implicit line joining)
()、[]、{}内的内容可以被切割成多个行,可以添加注释,
month_names = ['Januari', 'Februari', 'Maart', # These are the
'April', 'Mei', 'Juni', # Dutch names
'Juli', 'Augustus', 'September', # for the months
'Oktober', 'November', 'December'] # of the year
关键字(Keywords)
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 except in raise
保留的标识符类型(Reserved classes of identifiers)
_*
*
__*
除法
/
>>> 10 / 3
3.3333333333333335
>>> 9 / 3
3.0
//
>>> 10 // 3
3
%
>>> 10 % 3
1