试图通过使用str输入变量来制作一个运气轮计算器,作为课堂上的一项任务。
示例:
int(input("In which day of",a(defiend as a month inputed before),"were you born?"))
答案 0 :(得分:0)
您不能以这种方式这样做。您会得到一条错误消息,说明所有内容,输入仅包含一个(!)参数。这不是print():
TypeError: input expected at most 1 arguments, got 3
这对您有帮助吗?我利用了Python 3.7中引入的新f-Strings!
month = "april"
day = int(input(f"In which day of {month} were you born? "))
print(f"{day}. {month}")
如果您使用的是早期版本的Python,则必须使用.format(...):
month = "april"
day = int(input("In which day of {} were you born? ".format(month)))
print("{}. {}".format(day, month))
蟒蛇般快乐。