Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私はこのpythonの問題に悩まされています.月-日-年の形式の日付があり、年-月-日の形式に変更する必要があります
>>> import datetime >>> datetime.datetime.strptime("06/03/2015", "%m/%d/%Y").strftime("%Y-%m-%d") '2015-06-03'
これは、日付 (この場合は 2015 年 6 月 3 日) を文字列として受け取り、 を使用してそれを datetime オブジェクトに解析しますstrptime。次に、それを使用して、要求した形式 (YYYY-mm-dd) の文字列に変換します。strftime
strptime
strftime