Discuss / Python / 为什么显示没有group属性

为什么显示没有group属性

Topic source

最爱臭屁k

#1 Created at ... [Delete] [Delete and Lock User]

``` import re from datetime import datetime,timedelta def to_timestamp(dt_str,tz_str): x=datetime.strptime(dt_str,'%Y-%m-%d %H:%M:%S') #str 转datetime; m=re.match(r'(UTF)+(\d{1,2}):00',tz_str) s=int(m.group(2))#获得hours d=x-timedelta(hours=s)#获得UTF+0:00 return d.timestamp() t1=to_timestamp('2015-6-1 08:10:30','UTC+7:00') print (t1)

` AttributeError: 'NoneType' object has no attribute 'group'为什么不对啊,把获得hours那两句单独运行没错啊。求解答

最爱臭屁k

#2 Created at ... [Delete] [Delete and Lock User]

奥报错的原因是没匹配到,,def里边写成“UTF”了,应该是“UTC”改过来就就能调通了 。


  • 1

Reply