Python 个人常用命令

1、格式化时间,随机数,UUID

# -*- encoding=utf-8 -*-

import time
import uuid
import random

if __name__ == '__main__':
    # 格式化时间
    now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    print now  # 2020-07-23 10:14:19
    # UUID
    u = str(uuid.uuid1())
    print u  # 756e2f8f-cc8a-11ea-8773-d850e6d359bc
    # 随机数
    r = random.randint(0, 10)  # 包括0和10
    print r

猜你喜欢

转载自www.cnblogs.com/rainbow-tan/p/13364776.html
今日推荐