12
Định dạng một datetime thành một chuỗi với mili giây
Tôi muốn có một datetimechuỗi từ ngày với mili giây. Mã này là điển hình cho tôi và tôi rất muốn học cách rút ngắn nó. from datetime import datetime timeformatted= str(datetime.utcnow()) semiformatted= timeformatted.replace("-","") almostformatted= semiformatted.replace(":","") formatted=almostformatted.replace(".","") withspacegoaway=formatted.replace(" ","") formattedstripped=withspacegoaway.strip() print formattedstripped