William01 发表于 2024-8-5 15:37:36

为什么name = Alice 会报错?


提前谢谢各位大佬!

代码如下:
name = Alice
Traceback (most recent call last):
File "<pyshell#56>", line 1, in <module>
    name = Alice
NameError: name 'Alice' is not defined. Did you mean: 'slice'?

isdkz 发表于 2024-8-5 16:39:30

要加双引号才是字符串,不加双引号是变量名,你引用了未被定义的变量肯定是会报错的

name = "Alice"

William01 发表于 2024-8-5 17:06:07

isdkz 发表于 2024-8-5 16:39
要加双引号才是字符串,不加双引号是变量名,你引用了未被定义的变量肯定是会报错的

好的,非常感谢
页: [1]
查看完整版本: 为什么name = Alice 会报错?