【发布时间】:2018-07-30 20:45:36
【问题描述】:
尝试通过使用 str 输入变量将幸运轮计算器作为课堂任务。
例子:
int(input("In which day of",a(defiend as a month inputed before),"were you born?"))
【问题讨论】:
-
你的问题太宽泛了。请提供一些(缩进的)代码。
标签: string python-3.x variables input
尝试通过使用 str 输入变量将幸运轮计算器作为课堂任务。
例子:
int(input("In which day of",a(defiend as a month inputed before),"were you born?"))
【问题讨论】:
标签: string python-3.x variables input
你不能这样做。你会得到一个说明一切的错误,输入只需要一个(!)参数。这不是 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))
快乐的蟒蛇。
【讨论】:
int(input("In which day of" + month + "were you born? ")