注释(Python)

注释是用来说明代码
程序运行的时候,Python解释器会直接忽略掉注释 → 有没有注释不影响程序的执行结果,但是影响到别人能不能看懂你的代码。
但“#”不只代表注释,还代表某些文件的特殊格式,写在脚本开头

注意:注释只在脚本中起作用

print('hello world!')
# print('I love python')
hello world!

注释也可以用来标记暂时不会运行的语句

a = [1,2,3,4]
# a = {'name':'fatbird', 'city':'shanghai', 'tel':10001000}
for i in a:
    print(i)

1
2
3
4

若取消注释(字典无序)

city
tel
name



猜你喜欢

转载自blog.csdn.net/qq_39438455/article/details/80027510