【发布时间】:2021-03-16 18:03:59
【问题描述】:
from datetime import datetime, timedelta
from pytz import timezone
import pytz
import re
while True:
times=['Brazil','Hongkong','Australia','Mexico','US','Poland','Singapore','Portugal','Japan','Israel']
use=[times[0],times[2],times[3],times[4]]
print(r" enter the time zone that you want to watch ")
o=input(f"{times}\n").lower()
e=list(o)
if e=='us'or e=='usa' or e=='united state' or e=='untied states of america':
uy=list(e)
uy.remove(e[2:])
else:
mn=e[0].upper()+e[1:]
if mn not in times:
print("you need to enter time zone")
continue
else:
if mn and uy in use:
for i in re.findall(f'^{mn}'|f'{uy}',pytz.all_timezones):
u=list(re.findall(f'^{mn}'|f'{uy}',pytz.all_timezones))
if u[i]=='/':
u.remove(u[0:i])
print(u)
你好!我正在尝试创建一个代码,让我回到世界上不同的时区!虽然它还没有完成,我还处于起步阶段,但我不明白为什么这个错误出现在我看来 错误:
TypeError: can only concatenate str (not "list") to str
请不要点击“这个问题没有用”的标志,这对我没有帮助,我要求你宽容,如果你不明白,写在 cmets 中,我会尽力纠正
【问题讨论】:
-
错误出现在哪一行?
-
第17行出现此错误
标签: python string datetime utc python-re