我坚持要求我转换年份输入并在几秒钟内打印结果的作业。我运行该函数时收到的错误消息是:
'*TypeError: not all arguments converted during string formatting*'
我无法理解我的错误......
def ageInSeconds():
"""
Reads the age and converts to seconds.
"""
ageYears = int(input("Tell me your age, please: "))
seconds = ageYears * (365*24*60*60)
print("\nBatman says you age in seconds is: " % seconds)
答案 0 :(得分:4)
您在字符串中缺少%d
。
print("\nBatman says you age in seconds is: %d" % seconds)
^
否则你可以做到
print("\nBatman says you age in seconds is:",seconds) # Inbuilt feature of the print function