Commit 9e7442ff authored by Wei Shoulin's avatar Wei Shoulin
Browse files

random str

parent db048085
Pipeline #7312 passed with stage
from datetime import datetime
import time
import random
import string
def format_datetime(dt):
return dt.strftime('%Y-%m-%d %H:%M:%S')
......@@ -20,4 +22,12 @@ def format_time_ms(float_time):
return "%s.%03d" % (data_head, data_secs)
def str_to_datetime(str_time):
return datetime.strptime(str_time.split('.')[0], '%Y-%m-%d %H:%M:%S')
\ No newline at end of file
return datetime.strptime(str_time.split('.')[0], '%Y-%m-%d %H:%M:%S')
def rand_str(str_len = 4):
letters = string.digits
result_str = ''.join(random.choice(letters) for i in range(str_len))
return result_str
def rand_time_str(postfix_str_len = 4):
return format_compact_datetime(datetime.now()) + rand_str(postfix_str_len)
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment