你好,我是 python 和一般编程的新手(昨晚才开始!),我写了一个小程序,粘贴在下面:
name = str(input("please state your name: "))
print ("Welcome %s, your doomesday weapon of impolite mutant pigeons is ready for launch") %name
但是,这会不断返回此错误:
回溯(最近一次调用最后):文件“prog.py”,第 2 行,打印中(“欢迎 %s,你的不礼貌突变鸽子的末日武器已准备好发射”)%name TypeError: unsupported operand type(s) for %: 'NoneType' 和 'str'
现在我知道此类问题的通常答案是将输入从字符串转换为整数并调整使用的操作数类型以匹配。但是在这种情况下,我实际上想使用字符串形式的输入,那么问题出在哪里?
PS 我正在使用 Ideone.com 来编译这段代码。