python 프로 그래 밍 빠 른 시작 제8 장 실천 프로젝트 미 친 작성

import re
oldFile=open('C:/Users/Administrator/Desktop/test.txt')
newFile=open('C:/Users/Administrator/Desktop/test2.txt','w')
oldFileContent=oldFile.read()

tempFileContent=re.sub(r'[^a-zA-Z,\s]',"  .",oldFileContent)
print(tempFileContent)
tempFileList=tempFileContent.split(" ")
print(tempFileList)
keyWords=['ADJECTIVE','NOUN','ADVERB','VERB']
for i in range(len(tempFileList)):
    for j in range(len(keyWords)):             
        if(tempFileList[i] == keyWords[j]):
            print('Enter an '+keyWords[j]+':')
            tempFileList[i] = input()

newFileContent=' '.join(tempFileList).replace("  .",".")

print(newFileContent)
newFile.write(newFileContent)
oldFile.close()
newFile.close()

좋은 웹페이지 즐겨찾기