我刚开始Automate The Boring Stuff,我在第1章错误“无法将‘诠释’对象隐含STR”
myname = input()
print ('It is nice to meet you,' + myname)
lengthofname = len(myname)
print ('your name is this many letters:' + lengthofname)
我跑了这一点,它给了我Can't convert 'int' object to str implicitly
。 我在第3行的推理是我想要将变量myname
转换为整数,然后插入第4行。
为什么这会是一种错误的编码方式?
请看http://stackoverflow.com/questions/13654168/typeerror-cant-convert-int-object-to-str-implicitly。在发布之前,请谷歌。 –
使用逗号来分隔'print()'和'print()'中的参数会自动将它们转换为字符串 - 'print('你的名字是这么多字母:',lengthofname' – furas