早教吧 育儿知识 作业答案 考试题库 百科 知识分享

python报错TypeError:anintegerisrequired运行re.sub('X','Mr','Smith','attn:X\n\nDearX,\n')提示如下错误:Traceback(mostrecentcalllast):File"",line1,inre.sub('X','Mr','Smith','attn:X\n\nDearX,\n')File"D:\Pyehon273\lib\re.py",l

题目详情
python 报错TypeError:an integer is required
运行 re.sub('X','Mr','Smith','attn:X\n\nDear X,\n')
提示如下错误:Traceback (most recent call last):
File "",line 1,in
re.sub('X','Mr','Smith','attn:X\n\nDear X,\n')
File "D:\Pyehon2_7_3\lib\re.py",line 151,in sub
return _compile(pattern,flags).sub(repl,string,count)
TypeError:an integer is required
▼优质解答
答案和解析
参数写错了,第四个参数count是integer的
sub( pattern, repl, string[, count])