Skip to content

Instantly share code, notes, and snippets.

@lhsfcboy
Last active December 24, 2017 12:10
Show Gist options
  • Save lhsfcboy/389ca272d32eb55637884496d7877e82 to your computer and use it in GitHub Desktop.
Save lhsfcboy/389ca272d32eb55637884496d7877e82 to your computer and use it in GitHub Desktop.
Get timestamp from python
import time;
ts = time.time()
print(ts)
# 1514116641.1691682
# 小数点后七位,也就是100ns
import datetime;
ts = datetime.datetime.now().timestamp()
print(ts)
# 1514116641.171174
# 小数点后六位,也就是1微秒, 1us
import calendar;
import time;
ts = calendar.timegm(time.gmtime())
print(ts)
# 整数表示的秒值
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment