【发布时间】:2023-01-27 08:13:53
【问题描述】:
我尝试以两种方式加入示例字符串,首先通过代码输入,然后通过用户输入输入。我得到了不同的结果。
#为什么这些输出不一样(在 python 3.10.6 中):
sampleString = 'Fred','you need a nap! (your mother)'
ss1 = ' - '.join(sampleString)
print(ss1), print()
sampleString = input('please enter something: ') #entered 'Fred'
ss2 = ' - '.join(sampleString)
print(ss2)
输出:
Fred - you need a nap! (your mother)
please enter something: 'Fred'
' - F - r - e - d - '
【问题讨论】: