import os, string
print " "
setpath = raw_input("Ente r the path: ")
def find_replace(se tpath):
for root, dirs, files in os.walk(setpath ):
fname = files
for fname in files:
find = string.find(fil e(os.path.join( root,fname),
'rb').read(), 'THIS')
print find
if find >=1:
replace = string.replace( str, 'THIS', 'THAT')
find_replace(se tpath)
print " "
Why doesn't this work? I get this error:
Traceback (most recent call last):
File "html_find_repl ace.py", line 12, in ?
find_replace(se tpath)
File "html_find_repl ace.py", line 11, in find_replace
replace = string.replace( str, 'THIS', 'THAT')
File "/usr/local/lib/python2.3/string.py", line 370, in replace
return s.replace(old, new, maxsplit)
TypeError: expected a character buffer object
print " "
setpath = raw_input("Ente r the path: ")
def find_replace(se tpath):
for root, dirs, files in os.walk(setpath ):
fname = files
for fname in files:
find = string.find(fil e(os.path.join( root,fname),
'rb').read(), 'THIS')
print find
if find >=1:
replace = string.replace( str, 'THIS', 'THAT')
find_replace(se tpath)
print " "
Why doesn't this work? I get this error:
Traceback (most recent call last):
File "html_find_repl ace.py", line 12, in ?
find_replace(se tpath)
File "html_find_repl ace.py", line 11, in find_replace
replace = string.replace( str, 'THIS', 'THAT')
File "/usr/local/lib/python2.3/string.py", line 370, in replace
return s.replace(old, new, maxsplit)
TypeError: expected a character buffer object
Comment