BaşlayınÜcretsiz Başlayın

Turning strings into datetimes

When you download data from the Internet, dates and times usually come to you as strings. Often the first step is to turn those strings into datetime objects.

In this exercise, you will practice this transformation.

Reference
%Y4 digit year (0000-9999)
%m2 digit month (1-12)
%d2 digit day (1-31)
%H2 digit hour (0-23)
%M2 digit minute (0-59)
%S2 digit second (0-59)

Bu egzersiz

Working with Dates and Times in Python

kursunun bir parçasıdır
Kursu Görüntüle

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Import the datetime class
from datetime import datetime

# Starting string, in YYYY-MM-DD HH:MM:SS format
s = '2017-02-03 00:00:01'

# Write a format string to parse s
fmt = '____'

# Create a datetime object d
d = datetime.____(____, ____)

# Print d
print(d)
Kodu Düzenle ve Çalıştır