Python time模块

# time 模块
import time
now = time.time()
print('seconds gone from the beginning of 1970-1-1 00:00:', now)

# 用ctime(current time)方法将纪元值转换为 字符串

print('transverted time:', time.ctime(now))

# 使用localtime() 创建 struct_time对象

print('local time: ', time.localtime(now))

# 使用gmtime() 创建 struct_time对象

print('gmtime: ', time.gmtime(now))

# 用mktime() 将 struct_time 对象转换为纪元值

print('mktime: ', time.mktime(time.localtime(now)))

# 用 strftime() 格式化 字符串  // string from time?
fmt = 'Es ist %B, %d, %Y Örtliche Zeit: %A %H:%M:%S %p'

t = time.localtime()
print(time.strftime(fmt, t))

你可能感兴趣的:(Python time模块)