Python 的sub和replace的区别

没搞清这

test = re.sub('abd','adg','abdsss')

test = 'adgsss'

好使
new = '/a.html'
old = '/help/index.jsp?topic=/com.ibm.lotuslive.files.doc/documents_viewer_Files.html'  
line = '"text_helpurl" : "/help/index.jsp?topic=/com.ibm.lotuslive.files.doc/documents_viewer_Files.html"'
test = re.sub(old,new, line)

怎么就不好使了,非得用replace...


str.replace(old, new[, count])


你可能感兴趣的:(未解)