您的位置:首页 > 编程语言 > Python开发

Python知识点整理

2016-11-17 10:45 597 查看
参考

Python.Doc

廖雪峰的Python教程

显示连接(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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: