Making File Writable and Readable in Python -
i making find , replace script fix stuff on website. using python 3.3.2.
here code:
import re f = open('random.html', 'w') strtosearch = " " line in f: strtosearch += line patfinder1 = re.compile('<td>sermon title</td>\ <td><audio preload="none" controls src="http://www.orlandobiblechurch.org/audio/\d{6}ldm.mp3"></audio>\ </td>\ </tr>') findpat1 = re.search(patfinder1, strtosearch) findpat1 = re.findall(patfinder1, strtosearch) in findpat1: print(i) subfound = patfinder1.sub('<td>lord\'s day morning</td>\ <td><audio preload="none" controls src="http://www.orlandobiblechurch.org/audio/\d{6}ldm.mp3"></audio>\ </td>\ </tr>', strtosearch) print(subfound) f.write(subfound) f.close()
the problem python tells me file not readable. if changes f = open('random.html', 'w') f = open('random.html', 'r') this, says not writable. makes sense why needs both, if put both in, tells me there must 1 read/write thing. positive basic, can't figure out. can provide.
f = open('random.html', 'r+')
Comments
Post a Comment