【发布时间】:2021-03-06 09:44:03
【问题描述】:
我有这样的代码,但我不知道错误在哪里
x = int(input())
hh = x // 3600
second = x % 3600
mm = second // 60
ss = second % 60
print("%d remaining seconds is equal to %d:%d:%d".format(x, hh, second, mm, ss))
#Output
%d remaining seconds in equal to %d:%d:%d < I dont know why this code still %d and didnt change into numbers
当我使用print("%d remaining seconds is equal to %d:%d:%d" % (x, hh, second, mm, ss)) 时会出现错误not all arguments converted during string formatting
有什么建议吗?
【问题讨论】:
-
有关当前字符串格式化的方法,另请参阅:realpython.com/python-f-strings
标签: python python-3.x