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 from datetime import datetime
import time import time
import random
import string
def format_datetime(dt): def format_datetime(dt):
return dt.strftime('%Y-%m-%d %H:%M:%S') return dt.strftime('%Y-%m-%d %H:%M:%S')
...@@ -21,3 +23,11 @@ def format_time_ms(float_time): ...@@ -21,3 +23,11 @@ def format_time_ms(float_time):
def str_to_datetime(str_time): def str_to_datetime(str_time):
return datetime.strptime(str_time.split('.')[0], '%Y-%m-%d %H:%M:%S') 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