设置时区
现在您已经熟悉了逐个设置时区,接下来为车牌 W20529 的前 10 次行程设置时区。
timezone 和 timedelta 已经导入。请使用 .replace() 进行修改。
本练习是课程的一部分
在 Python 中处理日期和时间
练习说明
- 创建
edt,这是一个 UTC 偏移为 -4 小时的timezone对象。 - 在
for循环内: - 设置
trip['start']的tzinfo。 - 设置
trip['end']的tzinfo。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Create a timezone object corresponding to UTC-4
edt = ____
# Loop over trips, updating the start and end datetimes to be in UTC-4
for trip in onebike_datetimes[:10]:
# Update trip['start'] and trip['end']
trip['start'] = trip['start'].____
trip['end'] = trip['end'].____