pj_0004_time_swap
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import time
def _get_strftime_( t ):
return time.strftime("%Y%m%d %H:%M:%S", time.localtime(t))
def _get_mktime_( s, mode=0 ):
if mode == 1:
t = time.mktime( time.strptime(s, "%Y%m%d") )
else:
t = time.mktime( time.strptime(s, "%Y%m%d %H:%M:%S") )
return t
def _main_func_():
print(time.time(), time.strftime("%Y%m%d %H:%M:%S"))
print("welcome, please input your order")
print("mk for mktime, str for strftime")
ipt = input()
print("input para")
i = input()
if ipt == "mk":
print( _get_mktime_(i) )
elif ipt == 'str':
print( _get_strftime_(float(i)) )
def _test():
print('hello')
if __name__ == '__main__':
_main_func_()
浙公网安备 33010602011771号