我有一个方法,需要输入两个变量:
- 当前时间
- 分钟数
import time
class timeCalc(object):
def nextTime(self, time, minutes):
t = time.split(':')
mins = int(t[0]) * 60 + int(t[1]) + minutes
h = str(mins/60)
m = str(mins%60)
if len(h) == 1:
h = '0' + h
if len(m) == 1:
m = '0' + m
nTime = time.strptime(h + ':' + m, "%H:%M")
print nTime
ts = timeCalc()
ts.nextTime('23:01',60)
time
掩盖了time
模块,所以你的代码失败了。 - Martijn Pieters