How efficiently I can convert
date_format = "2019-01-30-10-07-50-000"
Expected output
"2019-01-30 10-07-50.000"
So far what I have tried :
ss = list(ss)
ss[10] = " "
ss[-4] = "."
print("".join(ss))
I Know i can do it using positional replacement using str replace() method, IS there any other efficient pythonic way , both are timestamps
date_format = "2019-01-30-10-07-50-000"
import datetime
d = datetime.datetime.strptime(date_format,"%Y-%m-%d-%H-%M-%S-000")
print(d.strftime("%Y-%d-%m %H-%M-%S.000"))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.