1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| import os import shutil
def createFile(content: str, folderPath: str, fileName: str): if not os.path.exists(folderPath): os.makedirs(folderPath) writeContent(folderPath + fileName, content)
def copyFile(fromPath: str, toPath: str): shutil.copy(fromPath, toPath)
def getFileContent(filePath: str, newline="\n", encoding="utf-8") -> str: file = open(filePath,'r', encoding=encoding, newline=newline) data = file.read() file.close() return data
def writeContent(filePath: str, content: str, newline="\n", encoding="utf-8"): file = open(filePath, "w+", encoding=encoding, newline=newline) file.write(content) file.close()
|