在请求输入定义新变量时使用以前的输入

2024-09-19 23:39:34 发布

您现在位置:Python中文网/ 问答频道 /正文

userName = input("What is your name?")

firstInteger = (input ("Hi," , userName , "what is the first integer?"))

就这样回来了 TypeError:输入最多需要1个参数,得到3个

我试着将用户名改为str(input(…)),将firstInteger输入中的用户名改为str(userName),但都没有工作或更改错误消息。你知道吗


Tags: thenameinputyourisusernameintegerhi
1条回答
网友
1楼 · 发布于 2024-09-19 23:39:34

以下是基于注释的更新代码。你知道吗

我也不确定您使用的是什么版本的python,但是旧版本可能需要raw_input而不是input。如果您使用的是python3.x,那么只要input就可以了。这是最新的代码。如果您使用的是python3,只需将raw_input替换为input。你知道吗

userName = raw_input("What is your name?")

firstInteger = (raw_input ("Hi," + userName + " what is the first integer?"))

相关问题 更多 >