This article describes how to modify the content of a text file in Python in batches. For more information about how to modify the content of a text file in Python in batches, see the following article, for more information, see
Python replaces file content in batches and supports nested folders
Import ospath = ". /"for root, dirs, files in OS. walk (path): for name in files: # print nameif name. endswith (". html "): # print root, dirs, name filename = root +"/"+ namef = open (filename," r ") filecontent =" "line = f. readline () while line: l = line. replace (":/arcgis_js_api", "/arcgisapi") filecontent = filecontent + lline = f. readline () f. close () f = file (filename, "w") f. writelines (filecontent) f. close ()
You can understand how to modify the content of text files in batches in Python described in this article. if you have any questions, please leave a message. the editor will reply to you in time!
For more details about how to modify the content of a text file in Python in batches, refer to the PHP Chinese website!