Skip to content

Instantly share code, notes, and snippets.

@laixintao
Created September 28, 2017 08:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laixintao/142347c7a2e00c432b8004c0ab4ce3bb to your computer and use it in GitHub Desktop.
Save laixintao/142347c7a2e00c432b8004c0ab4ce3bb to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
在命令行将python timestamp转换成人类可读的时间
Usage: pytp 1514131200
2017-12-25 00:00:00 +0800
"""
from __future__ import unicode_literals
import sys
import time
if __name__ == '__main__':
timestamp = int(sys.argv[1])
print(time.strftime('%Y-%m-%d %H:%M:%S %z',time.localtime(timestamp)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment