|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 13194608570 于 2018-1-9 22:54 编辑
这是自己求虐找的习题。。。初级中的初级,请不要笑话我。。。
# A comment,this is so you can read your program later.
# Anything after the # is ignored by ptthon.
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.")
以上是我自己打的代码,但是在CMD下运行报错
核对了很多遍找不到问题原因出在哪,我知道第一张图的代码是python2的代码,但是我加上了()还是不行
问题已经找到了,是因为print("I could have code like this."# and the comment after is ignored)的括号把#后边的解释句子括进去了,但是为什么括进去会出错,是因为#这个符号么?
print的参数可以是数字,也可以是字符串,你的程序中print("I could have code like this."# and the comment after is ignored)
前半部分是字符串,后面跟的就无法判断是什么了,这与#无关。例如
print('asd'fg)也是错的。
|
|