Python编程:语法、风格、内存管理与实例解析
1. Python基础语法规则
Python在语句和语法上有一些特定的规则和符号:
- 注释(#) :以 # 开头的内容为注释,解释器会忽略 # 到行尾的所有字符。例如:
# 这是一个注释
- 换行符(\n) :是标准的行分隔符,通常一行一个语句。
- 续行符(\) :当一个语句需要跨多行时,可以使用
\。例如:
if (weather_is_hot == 1) and \
(shark_warnings == 0) :
send_goto_beach_mesg_to_pager()
不过,在容器对象元素拆分和三引号字符串包含换行符时,可不用 \ 续行。如:
print '''hi there, this is a long message for you
that goes over multiple lines… you will find
out soon that triple quotes in Python allows
this kind o
超级会员免费看
订阅专栏 解锁全文
16万+

被折叠的 条评论
为什么被折叠?



