Timezone Examples
In the previous chapter, you saw one timezone: America/Edmonton. But the total number of even common timezones is quite big: more than 400! But you can see, that timezone by default contain continent name and city. So, we can explore the variety of timezones across the specific continent.
Since .all_timezones
and common_timezones
methods return lists, we can easily iterate over them. For example, using list comprehension, we can easily count the number of timezones containing 'America'.
123456# Load library import pytz # Count number of american timezones using list comprehension american_timezones = len([x for x in pytz.common_timezones if 'America' in x]) print(f"There are {american_timezones} american timezones available in pytz.common_timesones.")
Swipe to start coding
Iterate over .common_timezones
and print only timezones containing Europe
.
Solución
¡Gracias por tus comentarios!
single
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Resumir este capítulo
Explicar el código en file
Explicar por qué file no resuelve la tarea
Awesome!
Completion rate improved to 3.23
Timezone Examples
Desliza para mostrar el menú
In the previous chapter, you saw one timezone: America/Edmonton. But the total number of even common timezones is quite big: more than 400! But you can see, that timezone by default contain continent name and city. So, we can explore the variety of timezones across the specific continent.
Since .all_timezones
and common_timezones
methods return lists, we can easily iterate over them. For example, using list comprehension, we can easily count the number of timezones containing 'America'.
123456# Load library import pytz # Count number of american timezones using list comprehension american_timezones = len([x for x in pytz.common_timezones if 'America' in x]) print(f"There are {american_timezones} american timezones available in pytz.common_timesones.")
Swipe to start coding
Iterate over .common_timezones
and print only timezones containing Europe
.
Solución
¡Gracias por tus comentarios!
Awesome!
Completion rate improved to 3.23single