python报错记录

1.AttributeError: 'NoneType' object has no attribute 'group'python

import re
s=r'<title>kobe<\title>'
ret = re.search('<\w+><\\w+>',s)
print(ret.group(0))

属性错误: "NoneType"对象没有属性'group'
说明:search或者match返回回来的结果为'None',是空类型,因此在调用group的时候报错(说白了就是正则可能写的不对,没返回结果,就报错)

 2.StopIterationspa

li = [1,2,3,4]
ss = li.__iter__()
while 1:
    abc = ss.__next__()
    print(abc)

Traceback (most recent call last):
  File "E://python汇总/123.py", line 84, in <module>
    abc = ss.__next__()
StopIteration

生成器中止错误:是因为生成器里面没有数据能被迭代出来的时候,会报次错误,要在返回或者输出的地方作异常处理

 3.error: command 'gcc' failed with exit status 1code

因为没有正确安装Python开发环境致使
yum install python-devel

 

 

 

 

 

 

返回系列对象

相关文章
相关标签/搜索