20 lines
480 B
Python
20 lines
480 B
Python
import random
|
|
import time
|
|
|
|
|
|
class CommonUtils(object):
|
|
|
|
@staticmethod
|
|
def get_current_time():
|
|
"""获取当前时间"""
|
|
return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
|
|
|
@staticmethod
|
|
def random_code(length):
|
|
"""生成随机编码"""
|
|
choices = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
|
|
code = ''
|
|
for i in range(length):
|
|
code += random.choice(choices)
|
|
return code
|