Last active
August 29, 2015 14:12
-
-
Save lazybios/45124ae345727a0e399e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# coding: utf-8 | |
'''转换时间戳为实际时间 & 格式化时间''' | |
import time | |
import sys | |
if __name__ == "__main__": | |
if len(sys.argv) > 1: | |
print sys.argv[1],time.strftime("%H:%M:%S",time.localtime(float(sys.argv[1]))) | |
else: | |
print "format error ex: python xx.py 1419918180" | |
#格式化指定时间戳(非当前时间) | |
val = time.time() | |
time.strftime('%H:%M_%Y%m%d',time.gmtime(val)) | |
#=> 14:21_20150130 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment