Python: Convert contents of a file to Uppercase characters only

后端 未结 3 759
盖世英雄少女心
盖世英雄少女心 2021-01-22 02:28

I am trying to convert the contents a set of files to only uppercase characters. Heres the code I have so far:

import os

def test():
    os.chdir(\"C:/Users/Dav         


        
3条回答
  •  梦毁少年i
    2021-01-22 02:54

    def test():
    os.chdir("C:/Users/David/Files")
    files = os.listdir(".")
    for x in files:
        inputFile = open(x, "r")
        content = inputFile.read()
        with open(x, "wb") as outputFile:
                outputfile.write(str.upper(content))
                outputfile.close()
    

提交回复
热议问题