def prompt(n):
value=int(input("Please enter integer #", n ,":" , sep=""))
return value
value1=prompt(1)
错误:
value=int(input("请输入整数#", n ,":" , sep="")) TypeError: input() 没有关键字参数
def prompt(n):
value=int(input("Please enter integer #", n ,":" , sep=""))
return value
value1=prompt(1)
错误:
value=int(input("请输入整数#", n ,":" , sep="")) TypeError: input() 没有关键字参数
python中的input()
内置函数只需要1个参数-prompt。输入函数请参考python文档
编辑:根据您的评论,您需要更新提示以包含您发送的参数。请参阅下面的代码。正如评论中提到的 chris,f 字符串仅适用于 Python 3.6 版
def prompt(n):
value=int(input(f"Please enter integer {}".format(n)))
return value
对于 Python 版本 < 3.6,您可以使用旧格式字符串,如下面的代码所示
def prompt(n):
value=int(input("Please enter integer {}".format(n)))
return value