12
日時をミリ秒の文字列にフォーマットします
datetime日付からミリ秒の文字列が欲しい。このコードは私にとっては典型的なものであり、短縮する方法を学びたいと思っています。 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