guarantee-admin-api-v0.2/Modules/Common/CommonUtils.py

20 lines
480 B
Python
Raw Normal View History

2022-05-27 14:45:15 +08:00
import random
2022-05-25 14:41:58 +08:00
import time
class CommonUtils(object):
@staticmethod
def get_current_time():
2022-05-27 14:45:15 +08:00
"""获取当前时间"""
2022-05-25 14:41:58 +08:00
return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
2022-05-27 14:45:15 +08:00
@staticmethod
def random_code(length):
"""生成随机编码"""
choices = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
code = ''
for i in range(length):
code += random.choice(choices)
return code