You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- import time
- from datetime import datetime
-
- YY_MM_DD_HH_MM_SS = "%Y-%m-%d %H:%M:%S"
- YMDHMSF = "%Y%m%d%H%M%S%f"
-
-
- def generate_timestamp():
- """根据当前时间获取时间戳,返回整数"""
- return int(time.time())
-
-
- def now_date_to_str(fmt=None):
- if fmt is None:
- fmt = YY_MM_DD_HH_MM_SS
- return datetime.now().strftime(fmt)
-
- if __name__=="__main__":
- print(now_date_to_str(YMDHMSF))
|