Define class to use system time class,defineuse,import timec
文章由Byrx.net分享于2019-03-23 06:03:47
Define class to use system time class,defineuse,import timec
import timeclass now: def __init__(self): self.t = time.time() self.storetime() def storetime(self): self.year, self.month, self.day, self.hour, self.minute, self.second, \ self.dow, self.doy, \ self.dst = time.localtime(self.t)class today(now): def __init__(self, y = 1970): now.now.__init__(self) def update(self,tt): if len(tt) < 9 : raise TypeError if tt[0] < 1970 or tt[0] > 2038: raise OverflowError self.t = time.mktime(tt) self(self.t)if __name__ == '__main__': n = today() print 'The year is', n.year print n x = today() s = 'x' print s tt = (1999,7,16,12,59,59,0,0,-1) x.update(tt) print x
相关内容
- Deleting List Elements,deletingelements,li = ['a', '
- Mix quotations,mixquotations,title = 'Mea
- redis的python客户端demo代码,redispythondemo,Redis服务器的所
- For loop demo,forloopdemo,words = ['A'
- Introducing stdout and stderr,stdoutstderr,for i in ran
- Keyword Arguments Demo,keywordarguments,# Functions
- A tuple containing an integer,tuplecontaining,y = (40,)
- String concatenation Demo,,print 'You c
- Int, string, function, and list as list element,stringelement,foo =
- range() Function,rangefunction,# iterate ov
评论关闭