程序的注释是很重要的,它可以用自然语言告诉你某段代码的功能,注释里面的内容电脑不会对其进行编译。输出也无法看到。
这里继续复习一下建立文件的终端指令:
cd /users/simengred/mystuff
touch ex2.py
输入python代码:
# A comment,this is so you can read your program later
# anything after the #is ignored by python
print "I could have code like this" #and the comment after is ignored
# you can also use a comment to "disable" or comment out a piece of code
# print "this won't run"
print "this will run"
输出结果:
I could have code like this
this will run