我试图弄清楚来自世界各地的时间戳,让它更加直观。这是一个例子:
releaseDate: "2002-08-22T07:00:00Z" # only possible date format
据我所知,日期将被解释为:"2002-08-22 at 7a GMT"
。这是正确阅读上述内容吗?此外,是否有一个图书馆或类似的东西可以告诉我(大约)哪个国家适用,也就是说,TimeZone是+7 GMT。例如,在上文中,它可以被理解为:
"2002-08-22 in Los Angeles, CA"
这是阅读上述内容的最有用的方法(在我的例子中)。实现上述目标的最佳方法是什么?
答案 0 :(得分:4)
如果时间都是祖鲁时代,那么就时区而言,没有什么要解析它的日期字符串不是utc+7
它是7am
的utc。 ,如果您想使用utc时间查找其他时区的时间,可以使用pytz
lib:
from datetime import datetime
from pytz import timezone
import pytz
_utc = pytz.utc
dte = "2002-08-22T07:00:00Z"
utc = datetime.strptime(dte, "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=_utc)
for tz in pytz.all_timezones:
tz = timezone(tz)
print(tz)
print(utc.astimezone(tz))
如果你想根据你的时间找到午夜的时区:
dte = "2002-08-22T07:00:00Z"
print( datetime.strptime(dte, "%Y-%m-%dT%H:%M:%SZ"))
utc = datetime.strptime(dte, "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=_utc)
for tz in pytz.all_timezones:
tz = timezone(tz)
dt = (utc.astimezone(tz))
if str(dt.time()) == "00:00:00":
print(tz)
print(dt)
哪个会输出:
America/Creston
2002-08-22 00:00:00-07:00
America/Dawson
2002-08-22 00:00:00-07:00
America/Dawson_Creek
2002-08-22 00:00:00-07:00
America/Ensenada
2002-08-22 00:00:00-07:00
America/Hermosillo
2002-08-22 00:00:00-07:00
America/Los_Angeles
2002-08-22 00:00:00-07:00
America/Phoenix
2002-08-22 00:00:00-07:00
America/Santa_Isabel
2002-08-22 00:00:00-07:00
America/Tijuana
2002-08-22 00:00:00-07:00
America/Vancouver
2002-08-22 00:00:00-07:00
America/Whitehorse
2002-08-22 00:00:00-07:00
Canada/Pacific
2002-08-22 00:00:00-07:00
Canada/Yukon
2002-08-22 00:00:00-07:00
Etc/GMT+7
2002-08-22 00:00:00-07:00
MST
2002-08-22 00:00:00-07:00
Mexico/BajaNorte
2002-08-22 00:00:00-07:00
PST8PDT
2002-08-22 00:00:00-07:00
US/Arizona
2002-08-22 00:00:00-07:00
US/Pacific
2002-08-22 00:00:00-07:00
US/Pacific-New
2002-08-22 00:00:00-07:00
如果指定了偏移,则会高于2002-08-22 00:00:00-07:00
或2002-08-22 00:00:00+07:00
。您也可以使用偏移量创建一个数据库进行分组,并使用时间查看要查找的偏移量,以查找午夜的区域。
如果您需要两个字母的国家/地区代码:
from datetime import datetime
from pytz import timezone, country_timezones, utc
_utc = utc
dte = "2002-08-22T10:00:00Z"
utc = datetime.strptime(dte, "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=_utc)
coun_to_tz = {tz: coun for coun, v in country_timezones.items() for tz in v}
for _tz, coun in coun_to_tz.items():
tz = timezone(_tz)
dt = utc.astimezone(tz)
if str(dt.time()) == "00:00:00":
print(coun)
print(dt)
print(_tz)
输出:
CK
2002-08-22 00:00:00-10:00
Pacific/Rarotonga
PF
2002-08-22 00:00:00-10:00
Pacific/Tahiti
UM
2002-08-22 00:00:00-10:00
Pacific/Johnston
KI
2002-08-23 00:00:00+14:00
Pacific/Kiritimati
US
2002-08-22 00:00:00-10:00
Pacific/Honolulu
我使用了不同的utc开始时间,因此输出不同。
我从here中提取了ISO 3166-1-alpha-2英文国家/地区名称和代码元素,并创建了一个将两个字母代码映射到完整国家/地区名称的dict,因此至少输出会更多一些可以理解的:
from datetime import datetime
from pytz import timezone, utc
_utc = utc
dte = "2002-08-22T10:00:00Z"
utc = datetime.strptime(dte, "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=_utc)
coun_to_tz = {'Europe/Helsinki': 'Finland', 'Asia/Thimphu': 'Bhutan', 'Australia/Currie': 'Australia', 'Pacific/Niue': 'Niue', 'Asia/Dili': 'Timor-Leste', 'Europe/Kiev': 'Ukraine', 'Indian/Mahe': 'Seychelles', 'Asia/Kathmandu': 'Nepal', 'Asia/Aden': 'Yemen', 'Europe/Malta': 'Malta', 'Pacific/Noumea': 'New Caledonia', 'America/Bahia_Banderas': 'Mexico', 'Africa/Ceuta': 'Spain', 'Europe/Uzhgorod': 'Ukraine', 'Asia/Hebron': 'Palestine, State of', 'America/Indiana/Knox': 'United States', 'Europe/Kaliningrad': 'Russian Federation', 'America/Chicago': 'United States', 'Asia/Amman': 'Jordan', 'Europe/Isle_of_Man': 'Isle of Man', 'America/Guadeloupe': 'Guadeloupe', 'Europe/Copenhagen': 'Denmark', 'Indian/Maldives': 'Maldives', 'Pacific/Bougainville': 'Papua New Guinea', 'Africa/Banjul': 'Gambia', 'America/Cuiaba': 'Brazil', 'Pacific/Wake': 'United States Minor Outlying Islands', 'Antarctica/Mawson': 'Antarctica', 'America/Noronha': 'Brazil', 'America/Indiana/Tell_City': 'United States', 'America/Inuvik': 'Canada', 'Africa/Niamey': 'Niger', 'Africa/Juba': 'South Sudan', 'Atlantic/Reykjavik': 'Iceland', 'America/Curacao': 'Curaçao', 'Africa/Porto-Novo': 'Benin', 'Africa/Brazzaville': 'Congo', 'Atlantic/South_Georgia': 'South Georgia and the South Sandwich Islands', 'Asia/Baku': 'Azerbaijan', 'America/Detroit': 'United States', 'America/Monterrey': 'Mexico', 'America/Grenada': 'Grenada', 'Australia/Perth': 'Australia', 'Asia/Magadan': 'Russian Federation', 'Pacific/Fiji': 'Fiji', 'Pacific/Honolulu': 'United States', 'America/Thule': 'Greenland', 'America/Guyana': 'Guyana', 'America/Grand_Turk': 'Turks and Caicos Islands', 'America/Indiana/Petersburg': 'United States', 'Antarctica/Rothera': 'Antarctica', 'Europe/Vatican': 'Holy See (Vatican City State)', 'America/Cambridge_Bay': 'Canada', 'America/Marigot': 'Saint Martin (French part)', 'Africa/Sao_Tome': 'Sao Tome and Principe', 'Pacific/Palau': 'Palau', 'Asia/Gaza': 'Palestine, State of', 'America/Tortola': 'Virgin Islands, British', 'Asia/Yakutsk': 'Russian Federation', 'America/Argentina/Catamarca': 'Argentina', 'Pacific/Norfolk': 'Norfolk Island', 'America/Paramaribo': 'Suriname', 'Asia/Aqtobe': 'Kazakhstan', 'America/Anguilla': 'Anguilla', 'Africa/Douala': 'Cameroon', 'Asia/Chita': 'Russian Federation', 'Asia/Riyadh': 'Saudi Arabia', 'Africa/Mbabane': 'Swaziland', 'America/Argentina/San_Juan': 'Argentina', 'Europe/London': 'United Kingdom', 'Australia/Brisbane': 'Australia', 'Asia/Urumqi': 'China', 'America/Asuncion': 'Paraguay', 'America/Regina': 'Canada', 'Asia/Qyzylorda': 'Kazakhstan', 'Africa/Kigali': 'Rwanda', 'Africa/Dakar': 'Senegal', 'Asia/Jerusalem': 'Israel', 'Asia/Ashgabat': 'Turkmenistan', 'Asia/Kuala_Lumpur': 'Malaysia', 'Africa/Maputo': 'Mozambique', 'America/Glace_Bay': 'Canada', 'Africa/Malabo': 'Equatorial Guinea', 'Europe/Jersey': 'Jersey', 'America/Rankin_Inlet': 'Canada', 'America/Fortaleza': 'Brazil', 'Europe/Luxembourg': 'Luxembourg', 'Asia/Taipei': 'Taiwan, Province of China', 'Europe/Bratislava': 'Slovakia', 'Asia/Pontianak': 'Indonesia', 'Pacific/Chuuk': 'Micronesia, Federated States of', 'Indian/Chagos': 'British Indian Ocean Territory', 'America/Cayman': 'Cayman Islands', 'Atlantic/Madeira': 'Portugal', 'Africa/El_Aaiun': 'Western Sahara', 'America/Indiana/Winamac': 'United States', 'America/St_Kitts': 'Saint Kitts and Nevis', 'Asia/Tbilisi': 'Georgia', 'America/Yellowknife': 'Canada', 'Atlantic/St_Helena': 'Saint Helena, Ascension and Tristan da Cunha', 'Asia/Novokuznetsk': 'Russian Federation', 'Africa/Libreville': 'Gabon', 'Europe/Brussels': 'Belgium', 'America/Guatemala': 'Guatemala', 'Europe/Simferopol': 'Russian Federation', 'Europe/Vaduz': 'Liechtenstein', 'Africa/Harare': 'Zimbabwe', 'America/Goose_Bay': 'Canada', 'America/Indiana/Indianapolis': 'United States', 'Africa/Cairo': 'Egypt', 'Asia/Bishkek': 'Kyrgyzstan', 'Asia/Sakhalin': 'Russian Federation', 'Asia/Nicosia': 'Cyprus', 'America/St_Thomas': 'Virgin Islands, U.S.', 'Europe/Sarajevo': 'Bosnia and Herzegovina', 'Pacific/Johnston': 'United States Minor Outlying Islands', 'Atlantic/Cape_Verde': 'Cape Verde', 'America/Tegucigalpa': 'Honduras', 'Australia/Eucla': 'Australia', 'Pacific/Tahiti': 'French Polynesia', 'Africa/Tripoli': 'Libya', 'Australia/Sydney': 'Australia', 'America/Kentucky/Monticello': 'United States', 'Antarctica/Palmer': 'Antarctica', 'Asia/Tokyo': 'Japan', 'Asia/Baghdad': 'Iraq', 'America/Dawson_Creek': 'Canada', 'America/Bogota': 'Colombia', 'Pacific/Chatham': 'New Zealand', 'America/Scoresbysund': 'Greenland', 'Pacific/Pitcairn': 'Pitcairn', 'Europe/Madrid': 'Spain', 'America/Ojinaga': 'Mexico', 'America/Campo_Grande': 'Brazil', 'America/Lima': 'Peru', 'America/Metlakatla': 'United States', 'America/Boise': 'United States', 'Atlantic/Bermuda': 'Bermuda', 'America/Kralendijk': 'Bonaire, Sint Eustatius and Saba', 'America/Edmonton': 'Canada', 'Asia/Kabul': 'Afghanistan', 'America/Maceio': 'Brazil', 'Europe/Stockholm': 'Sweden', 'Asia/Oral': 'Kazakhstan', 'Pacific/Efate': 'Vanuatu', 'Europe/Athens': 'Greece', 'Europe/Rome': 'Italy', 'America/St_Lucia': 'Saint Lucia', 'Africa/Addis_Ababa': 'Ethiopia', 'Asia/Aqtau': 'Kazakhstan', 'America/Indiana/Marengo': 'United States', 'America/Port_of_Spain': 'Trinidad and Tobago', 'Africa/Lubumbashi': 'Congo, the Democratic Republic of the', 'America/Moncton': 'Canada', 'Africa/Bangui': 'Central African Republic', 'Asia/Samarkand': 'Uzbekistan', 'America/Cayenne': 'French Guiana', 'Europe/Zurich': 'Switzerland', 'America/Adak': 'United States', 'America/Argentina/San_Luis': 'Argentina', 'America/Mexico_City': 'Mexico', 'Australia/Lindeman': 'Australia', 'Pacific/Funafuti': 'Tuvalu', 'Asia/Jayapura': 'Indonesia', 'Pacific/Saipan': 'Northern Mariana Islands', 'America/Santo_Domingo': 'Dominican Republic', 'Africa/Freetown': 'Sierra Leone', 'America/Aruba': 'Aruba', 'Asia/Yekaterinburg': 'Russian Federation', 'Europe/Ljubljana': 'Slovenia', 'America/Iqaluit': 'Canada', 'America/Caracas': 'Venezuela, Bolivarian Republic of', 'Europe/Zaporozhye': 'Ukraine', 'Indian/Christmas': 'Christmas Island', 'Asia/Krasnoyarsk': 'Russian Federation', 'America/Los_Angeles': 'United States', 'America/St_Vincent': 'Saint Vincent and the Grenadines', 'Europe/Prague': 'Czech Republic', 'Africa/Monrovia': 'Liberia', 'Africa/Gaborone': 'Botswana', 'America/Cancun': 'Mexico', 'Pacific/Wallis': 'Wallis and Futuna', 'Asia/Qatar': 'Qatar', 'Asia/Bahrain': 'Bahrain', 'America/Boa_Vista': 'Brazil', 'America/Santa_Isabel': 'Mexico', 'Antarctica/Macquarie': 'Australia', 'America/Eirunepe': 'Brazil', 'America/Guayaquil': 'Ecuador', 'Africa/Accra': 'Ghana', 'America/Matamoros': 'Mexico', 'Africa/Conakry': 'Guinea', 'America/Araguaina': 'Brazil', 'Pacific/Gambier': 'French Polynesia', 'America/Puerto_Rico': 'Puerto Rico', 'America/Halifax': 'Canada', 'Asia/Pyongyang': "Korea, Democratic People's Republic of", 'America/Miquelon': 'Saint Pierre and Miquelon', 'Africa/Maseru': 'Lesotho', 'America/Thunder_Bay': 'Canada', 'Europe/Dublin': 'Ireland', 'Europe/Moscow': 'Russian Federation', 'Pacific/Pago_Pago': 'American Samoa', 'America/New_York': 'United States', 'Africa/Kampala': 'Uganda', 'Africa/Mogadishu': 'Somalia', 'Africa/Blantyre': 'Malawi', 'America/Argentina/Mendoza': 'Argentina', 'Europe/Sofia': 'Bulgaria', 'America/Nome': 'United States', 'Indian/Mayotte': 'Mayotte', 'Europe/Warsaw': 'Poland', 'Asia/Almaty': 'Kazakhstan', 'Pacific/Apia': 'Samoa', 'America/Kentucky/Louisville': 'United States', 'America/Winnipeg': 'Canada', 'America/Nipigon': 'Canada', 'Pacific/Nauru': 'Nauru', 'Asia/Seoul': 'Korea, Republic of', 'America/Menominee': 'United States', 'America/Argentina/Cordoba': 'Argentina', 'America/Rainy_River': 'Canada', 'Pacific/Majuro': 'Marshall Islands', 'America/Porto_Velho': 'Brazil', 'Asia/Vientiane': "Lao People's Democratic Republic", 'Europe/Guernsey': 'Guernsey', 'America/North_Dakota/Center': 'United States', 'Africa/Lusaka': 'Zambia', 'Pacific/Kwajalein': 'Marshall Islands', 'America/Port-au-Prince': 'Haiti', 'Europe/Vilnius': 'Lithuania', 'Europe/Vienna': 'Austria', 'Asia/Manila': 'Philippines', 'Africa/Djibouti': 'Djibouti', 'Asia/Jakarta': 'Indonesia', 'Africa/Windhoek': 'Namibia', 'Asia/Macau': 'Macao', 'Africa/Kinshasa': 'Congo, the Democratic Republic of the', 'America/Swift_Current': 'Canada', 'Africa/Lome': 'Togo', 'Asia/Vladivostok': 'Russian Federation', 'America/Belize': 'Belize', 'Europe/Amsterdam': 'Netherlands', 'Africa/Nouakchott': 'Mauritania', 'Asia/Singapore': 'Singapore', 'Europe/Riga': 'Latvia', 'Europe/Berlin': 'Germany', 'Africa/Lagos': 'Nigeria', 'Australia/Broken_Hill': 'Australia', 'America/Pangnirtung': 'Canada', 'Asia/Omsk': 'Russian Federation', 'Europe/Tallinn': 'Estonia', 'Africa/Bujumbura': 'Burundi', 'America/Managua': 'Nicaragua', 'Africa/Bissau': 'Guinea-Bissau', 'Europe/Paris': 'France', 'Asia/Rangoon': 'Myanmar', 'Europe/Chisinau': 'Moldova, Republic of', 'Asia/Irkutsk': 'Russian Federation', 'Asia/Hovd': 'Mongolia', 'America/Antigua': 'Antigua and Barbuda', 'America/Rio_Branco': 'Brazil', 'Asia/Srednekolymsk': 'Russian Federation', 'America/Belem': 'Brazil', 'America/Santarem': 'Brazil', 'America/Danmarkshavn': 'Greenland', 'Pacific/Kiritimati': 'Kiribati', 'America/Panama': 'Panama', 'America/Bahia': 'Brazil', 'Asia/Yerevan': 'Armenia', 'America/Indiana/Vevay': 'United States', 'America/Lower_Princes': 'Sint Maarten (Dutch part)', 'Africa/Asmara': 'Eritrea', 'America/Argentina/Ushuaia': 'Argentina', 'Atlantic/Canary': 'Spain', 'Asia/Phnom_Penh': 'Cambodia', 'America/Mazatlan': 'Mexico', 'America/Argentina/Tucuman': 'Argentina', 'Antarctica/Davis': 'Antarctica', 'America/Argentina/La_Rioja': 'Argentina', 'Pacific/Port_Moresby': 'Papua New Guinea', 'Asia/Muscat': 'Oman', 'Pacific/Enderbury': 'Kiribati', 'America/Havana': 'Cuba', 'America/Argentina/Jujuy': 'Argentina', 'Europe/San_Marino': 'San Marino', 'Asia/Kuwait': 'Kuwait', 'Pacific/Fakaofo': 'Tokelau', 'America/North_Dakota/Beulah': 'United States', 'America/Dominica': 'Dominica', 'Antarctica/DumontDUrville': 'Antarctica', 'Atlantic/Stanley': 'Falkland Islands (Malvinas)', 'Asia/Tehran': 'Iran, Islamic Republic of', 'Asia/Dushanbe': 'Tajikistan', 'Asia/Bangkok': 'Thailand', 'Africa/Ouagadougou': 'Burkina Faso', 'America/Sao_Paulo': 'Brazil', 'Australia/Lord_Howe': 'Australia', 'Antarctica/Syowa': 'Antarctica', 'Europe/Oslo': 'Norway', 'Asia/Tashkent': 'Uzbekistan', 'America/Phoenix': 'United States', 'Antarctica/Vostok': 'Antarctica', 'Europe/Istanbul': 'Turkey', 'Asia/Khandyga': 'Russian Federation', 'Pacific/Tarawa': 'Kiribati', 'Australia/Hobart': 'Australia', 'Pacific/Easter': 'Chile', 'Europe/Monaco': 'Monaco', 'America/Juneau': 'United States', 'Europe/Skopje': 'Macedonia, the Former Yugoslav Republic of', 'Australia/Darwin': 'Australia', 'America/Sitka': 'United States', 'America/Denver': 'United States', 'Asia/Kuching': 'Malaysia', 'Asia/Makassar': 'Indonesia', 'America/Hermosillo': 'Mexico', 'Asia/Hong_Kong': 'Hong Kong', 'Asia/Kolkata': 'India', 'Asia/Brunei': 'Brunei Darussalam', 'Asia/Anadyr': 'Russian Federation', 'Pacific/Rarotonga': 'Cook Islands', 'America/La_Paz': 'Bolivia, Plurinational State of', 'America/Martinique': 'Martinique', 'America/North_Dakota/New_Salem': 'United States', 'America/St_Barthelemy': 'Saint Barthélemy', 'Europe/Samara': 'Russian Federation', 'Asia/Dubai': 'United Arab Emirates', 'Africa/Johannesburg': 'South Africa', 'America/Blanc-Sablon': 'Canada', 'Indian/Comoro': 'Comoros', 'Asia/Kamchatka': 'Russian Federation', 'Asia/Ulaanbaatar': 'Mongolia', 'America/St_Johns': 'Canada', 'Europe/Bucharest': 'Romania', 'Pacific/Auckland': 'New Zealand', 'Africa/Luanda': 'Angola', 'Africa/Algiers': 'Algeria', 'Asia/Shanghai': 'China', 'America/Creston': 'Canada', 'America/Argentina/Salta': 'Argentina', 'America/Nassau': 'Bahamas', 'America/Dawson': 'Canada', 'America/Yakutat': 'United States', 'Antarctica/Casey': 'Antarctica', 'Europe/Podgorica': 'Montenegro', 'America/Manaus': 'Brazil', 'America/Atikokan': 'Canada', 'America/Recife': 'Brazil', 'Africa/Bamako': 'Mali', 'America/Vancouver': 'Canada', 'Indian/Kerguelen': 'French Southern Territories', 'Indian/Mauritius': 'Mauritius', 'Europe/Mariehamn': 'Åland Islands', 'Europe/Lisbon': 'Portugal', 'Antarctica/Troll': 'Antarctica', 'Europe/Budapest': 'Hungary', 'America/Argentina/Rio_Gallegos': 'Argentina', 'Australia/Melbourne': 'Australia', 'Europe/Belgrade': 'Serbia', 'Asia/Ust-Nera': 'Russian Federation', 'Pacific/Tongatapu': 'Tonga', 'Pacific/Pohnpei': 'Micronesia, Federated States of', 'Europe/Zagreb': 'Croatia', 'Asia/Karachi': 'Pakistan', 'Africa/Tunis': 'Tunisia', 'America/Merida': 'Mexico', 'Europe/Tirane': 'Albania', 'America/Anchorage': 'United States', 'Europe/Busingen': 'Germany', 'America/Montevideo': 'Uruguay', 'America/El_Salvador': 'El Salvador', 'Europe/Volgograd': 'Russian Federation', 'Pacific/Kosrae': 'Micronesia, Federated States of', 'Africa/Khartoum': 'Sudan', 'America/Santiago': 'Chile', 'Europe/Andorra': 'Andorra', 'Atlantic/Azores': 'Portugal', 'Europe/Minsk': 'Belarus', 'Asia/Colombo': 'Sri Lanka', 'Asia/Dhaka': 'Bangladesh', 'Pacific/Guadalcanal': 'Solomon Islands', 'Asia/Choibalsan': 'Mongolia', 'America/Argentina/Buenos_Aires': 'Argentina', 'Arctic/Longyearbyen': 'Svalbard and Jan Mayen', 'America/Chihuahua': 'Mexico', 'Indian/Cocos': 'Cocos (Keeling) Islands', 'Australia/Adelaide': 'Australia', 'Pacific/Midway': 'United States Minor Outlying Islands', 'Pacific/Guam': 'Guam', 'Africa/Casablanca': 'Morocco', 'Africa/Abidjan': "Côte d'Ivoire", 'Indian/Reunion': 'Réunion', 'Europe/Gibraltar': 'Gibraltar', 'America/Tijuana': 'Mexico', 'Asia/Ho_Chi_Minh': 'Viet Nam', 'Africa/Ndjamena': 'Chad', 'America/Montserrat': 'Montserrat', 'America/Resolute': 'Canada', 'Pacific/Marquesas': 'French Polynesia', 'Pacific/Galapagos': 'Ecuador', 'Atlantic/Faroe': 'Faroe Islands', 'America/Costa_Rica': 'Costa Rica', 'Asia/Beirut': 'Lebanon', 'America/Whitehorse': 'Canada', 'Africa/Nairobi': 'Kenya', 'Africa/Dar_es_Salaam': 'Tanzania, United Republic of', 'America/Godthab': 'Greenland', 'Asia/Damascus': 'Syrian Arab Republic', 'America/Toronto': 'Canada', 'America/Indiana/Vincennes': 'United States', 'Antarctica/McMurdo': 'Antarctica', 'Indian/Antananarivo': 'Madagascar', 'America/Jamaica': 'Jamaica', 'America/Barbados': 'Barbados', 'Asia/Novosibirsk': 'Russian Federation'}
for _tz, coun in coun_to_tz.items():
tz = timezone(_tz)
dt = utc.astimezone(tz)
if str(dt.time()) == "10:00:00":
print(dt.strftime("%A %B %d at %I:%M:%S%p in {}".format(coun)))
输出:
Thursday August 22 at 10:00:00AM in Mauritania
Thursday August 22 at 10:00:00AM in Antarctica
Thursday August 22 at 10:00:00AM in Liberia
Thursday August 22 at 10:00:00AM in Sierra Leone
Thursday August 22 at 10:00:00AM in Sao Tome and Principe
Thursday August 22 at 10:00:00AM in Mali
Thursday August 22 at 10:00:00AM in Guinea
Thursday August 22 at 10:00:00AM in Senegal
Thursday August 22 at 10:00:00AM in Gambia
Thursday August 22 at 10:00:00AM in Togo
Thursday August 22 at 10:00:00AM in Iceland
Thursday August 22 at 10:00:00AM in Portugal
Thursday August 22 at 10:00:00AM in Burkina Faso
Thursday August 22 at 10:00:00AM in Western Sahara
Thursday August 22 at 10:00:00AM in Côte d'Ivoire
Thursday August 22 at 10:00:00AM in Greenland
Thursday August 22 at 10:00:00AM in Morocco
Thursday August 22 at 10:00:00AM in Ghana
Thursday August 22 at 10:00:00AM in Guinea-Bissau
Thursday August 22 at 10:00:00AM in Saint Helena, Ascension and Tristan da Cunha
Thursday August 22 at 10:00:00AM in Greenland