MulaiMulai sekarang secara gratis

What time did the bike leave? (Global edition)

When you need to move a datetime from one timezone into another, use .astimezone() and tz. Often you will be moving things into UTC, but for fun let's try moving things from 'America/New_York' into a few different time zones.

Latihan ini adalah bagian dari kursus

Working with Dates and Times in Python

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Create the timezone object
uk = ____

# Pull out the start of the first trip
local = onebike_datetimes[0]['start']

# What time was it in the UK?
notlocal = local.____(____)

# Print them out and see the difference
print(local.isoformat())
print(notlocal.isoformat())
Edit dan Jalankan Kode