习题2 注释和井号
#!usr/bin/python
#--coding:utf-8--
#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.
其他:
- #:井号后面的内容均会被忽略不输出
- 行首加#代表注释
- print “hello # world!”:会打印出hello # world!,由于#在引号内部,当成了字符串的一部分进行处理,而不是用作注释功能