我有以下代码:# function to truncate filesdef truncate(path): file_to_truncate = open(path, "w") file_to_truncate.truncate() file_to_truncate.close()# truncate all relevant files so they are empty and new results are not written underneath another set of resultstruncate(r'outputA.csv')truncate(r'\outputB.csv')truncate(r'outputC.csv')truncate(r'outputD.csv')truncate(r'outputE.csv')truncate(r'MoutputA.csv')truncate(r'MoutputB.csv')truncate(r'MoutputC.csv')truncate(r'MoutputD.csv')truncate(r"Full Results.csv")truncate(r'results.csv')是否可以缩短此代码,即截断目录中的所有文件。
添加回答
举报
0/150
提交
取消