|

楼主 |
发表于 2021-8-22 19:41:10
|
显示全部楼层
输入
print("你知道什么是变量吗?")
temp = input("请选择:“知道”或“不知道”\n")
guess = int(temp)
if guess = 知道:
print("那没事了。")
else:
print("回忆一下叭。")
print("形如\"x=y\"这类格式就是变量,给x一个暂时确定的值,在后续可以进行更改和运算")
print("你知道什么是字符串吗?")
temp = input("请选择:\“知道或\”\“不知道\”")
guess = int(tem)
if guess == 知道:
print("那没事了。")
else:
print("回忆一下叭。")
print("520属于字符,而\"520\"属于字符串\(注意双引号\)")
是这样改吗?
但是改完后就变成这样了
你知道什么是变量吗?
请选择:“知道”或“不知道”
知道
Traceback (most recent call last):
File "D:/11/第二课(变量和字符串)/第二课代码.py", line 6, in <module>
guess = int(temp)
ValueError: invalid literal for int() with base 10: '知道'
|
|