使用链接的串联和一个空格字符串\“ \”

问题描述 投票:0回答:1
world = 'World'

hello_world =hello +''+ World
print(hello_world)      # Note: you should print "Hello World"

结果

Traceback (most recent call last):
  /PycharmProjects/Introduction to Python/Strings/Concatenation/concatenation.py", line 4, in <module>
    hello_world =hello +''+ World
NameError: name 'World' is not defined

Process finished with exit code 1
python pycharm
1个回答
0
投票

Python变量区分大小写,因此变量Worldworld不同。

[hello_world =hello +''+ World应该是hello_world = hello + '' + world

© www.soinside.com 2019 - 2024. All rights reserved.