python3中的布爾型變量賦值問題
x = "There are %d types of people." % 10
binary = "binary"
do_not = "don't"
y = "Those who know %s and those who %s." % (binary,do_not)
print (x)
print (y)
print ("I said: %r." % x)
print (("I also said: '%s'." % y)
hilarious = False
joke_evaluation = "Isn't that joke so funny?! %r"
print (joke_evaluation % hilarious)
w = "This is thhe left side of..."
e = "a string with a right side."
print (w + e)
比如在python3中這段代碼運行不了,錯誤提示如下
? File "ex6.py", line 12
? ? hilarious = False
? ? ? ? ? ? ^
SyntaxError: invalid syntax
但是如果我單獨把后面提取出來
hilarious = False
joke_evaluation = "Isn't that joke so funny?! %r"
print (joke_evaluation % hilarious)
w = "This is thhe left side of..."
e = "a string with a right side."
這樣是可以運行的
這其中對于hilarious = False的賦值是有什么要求的么?
2018-07-14
額。。我用3.6能運行= =直接copy你全部代碼運行的