Python 으로 폴더안의 텍스트 파일들의 문자열 replace 하기이다.
# https://stackoverflow.com/questions/50037369/find-and-replace-string-from-multiple-files-in-a-folder-using-python
import glob
for f in glob.glob("*.[ch]"):
with open(f, "r") as inputfile:
newText = inputfile.read().replace('Version1', 'Version2.2.1')
with open(f, "w") as outputfile:
outputfile.write(newText)
'파이썬 언어' 카테고리의 다른 글
| Python으로 폴더안의 모든 사진에 워터마크 넣기 (0) | 2021.09.21 |
|---|---|
| Python으로 image 파일을 만들고 문자를 넣는 방법 (1) | 2021.09.21 |
| Python으로 음성합성하기 (2) (1) | 2021.09.16 |
| Python으로 음성합성하기 (1) (0) | 2021.09.16 |
| 파이썬으로 유튜브 자막 받기(약간 많이 불편함) (0) | 2021.09.12 |
댓글