1.在列表逗号后面加空格:
["lilei", "hanmeimei", "lixue", "xiaoming"]
2.语句结尾加注释:
需要两个空格 + # + 一个空格 注释内容
for i in range(3): # 循环次数为3
3.单行注释:
需要# + 空格 注释内容
# 否则输出剩余的次数 并 跳出本次循环
4.函数之间空两行回车两次(去出波浪线)
def pizza(size, *toppings):
"""扫描顾客点的所有配料"""
print("\nMaking a " + str(size) + "-inch pizza with the following toppings: ")
for topping in toppings:
print("- " + topping)
def greet_user(names):
"""向列表中的每位用户都发出简单的问候"""
for name in names:
msg = "hello, " + name.title() + '!'
print(msg)
5.大招:PyCharm格式化代码快捷键
PyCharm自带代码格式化快捷键Ctrl+Shift+Alt+L或Ctrl+Alt+L,一键标准化你的代码,专治强迫症。(当然,改不了bug)