Python TypeError:raw_input()接受1到2个位置参数,但给出了4个
所以我是python新手,目前正在学习函数。所以我创建了一个下面的函数,我不知道为什么它不起作用Python TypeError:raw_input()接受1到2个位置参数,但给出了4个,python,function,Python,Function,所以我是python新手,目前正在学习函数。所以我创建了一个下面的函数,我不知道为什么它不起作用 def open_netflix(): print('Opening Netflix') x = str(input('Enter the Season you want to play: ')) y = int(input('Which season of',x,'you want to play?')) z = int(input('Which episo
def open_netflix():
print('Opening Netflix')
x = str(input('Enter the Season you want to play: '))
y = int(input('Which season of',x,'you want to play?'))
z = int(input('Which episode?'))
print('Playing',x,y,z)
我收到的错误消息是:
Opening Netflix
Enter the Season you want to play: Breaking Bad
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-18-82ce4ad2e7d2> in <module>
----> 1 open_netflix()
<ipython-input-17-917a60c59ffa> in open_netflix()
2 print('Opening Netflix')
3 x = str(input('Enter the Season you want to play: '))
----> 4 y = int(input('Which season of',x,'you want to play?'))
5 z = int(input('Which episode?'))
6 print('Playing',x,y,z)
TypeError: raw_input() takes from 1 to 2 positional arguments but 4 were given
打开Netflix
进入你想玩的赛季:打破坏习惯
---------------------------------------------------------------------------
TypeError回溯(最近一次调用上次)
在里面
---->1 open_netflix()
在open_netflix()中
2打印(“打开Netflix”)
3 x=str(输入('输入您想玩的赛季:'))
---->4y=int(输入('x,'你想玩哪个赛季?'))
5z=int(输入(‘哪一集?’)
6打印(“播放”,x,y,z)
TypeError:raw_input()接受1到2个位置参数,但给出了4个
我不知道是什么问题。期待帮助。
输入
与打印
不同;它不会将其参数连接到单个字符串中。您需要自己完成,例如使用f字符串
x = int(input(f'Which season of {x} do you want to play?')
输入
不像打印
;它不会将其参数连接到单个字符串中。您需要自己完成,例如使用f字符串
x = int(input(f'Which season of {x} do you want to play?')
input
只接受一个参数。您在线路上通过了三个:
y=int(输入('x,'x,你想玩哪个赛季?'))
请看
你可能想试试f字串。
输入
只接受一个参数。您在线路上通过了三个:
y=int(输入('x,'x,你想玩哪个赛季?'))
请看
你可能想试试f字串。
为什么错误提到
raw\u input
(一个仅Python-2的函数)而不是input
,这是您代码中实际存在的错误?为什么错误提到raw\u input
(仅Python-2的函数)而不是input
,这是您代码中实际存在的错误?是的,我读过了。我不熟悉f字串这个词。现在我是。谢谢。是的,我读过了。我不熟悉f字串这个词。现在我是。非常感谢。