亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

PYTHON 3 我需要幫助。我已經檢查過類似的問題。TypeError:輸入預計最多 1 個參數

PYTHON 3 我需要幫助。我已經檢查過類似的問題。TypeError:輸入預計最多 1 個參數

守候你守候我 2023-06-27 17:57:36
這是我的錯誤。Traceback (most recent call last):  File "<stdin>", line 1, in <module>  File "main.py", line 21, in welcome    name2 = input("\nPardon? Did you say",name+"?")TypeError: input expected at most 1 argument, got 2這是我的代碼。import randomimport timedef welcome():  #Tutorial  print("============================================")  print("Welcome to Blunderberg RPG by ChillingPixel")  print("The goal is just to have fun and stay alive.")  print("Yes, No, North, South East, West, are all ")  print("valid inputs.")  print("                 Have fun!")  print("============================================")# Meeting Old Man Thorley  time.sleep(5)  name = input("\nBed and Breakfast Owner:\nWelcome Young traveler what is your name? ")  time.sleep(2)  print("Nice to meet you",name,". My name is Old Man Tho—. Wait! Did you say your name was",name,"?")    time.sleep(3)  name2 = input("\nPardon? Did you say",name+"?")  if name2 in("Yes,yes,yea,Yea,Yeah,yea,y,Y"):    game()def game():  time.sleep(3)  print("Testing 123")我希望用戶能夠確認這就是他所說的,如果他說是,那么他就會進入游戲()。抱歉,我是 Python 新手
查看完整描述

1 回答

?
楊魅力

TA貢獻1811條經驗 獲得超6個贊

將逗號替換為 + 號


name2 = input("\nPardon? Did you say"+name+"?")


# or use f-string, same result

name2 = input(f"\nPardon? Did you say {name} ?")


您需要連接字符串。通過使用逗號,您將傳遞兩個參數。但 input() 僅接受一個參數


查看完整回答
反對 回復 2023-06-27
  • 1 回答
  • 0 關注
  • 325 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號