FileOpen工具类存在Bug,内部抵用open函数的时候没有指定参数,导致参数类型不匹配。这里进行了参数的指定,修复Bug。同时对read时文件不存在,创造文件存在的隐藏问题进行了修改。
							parent
							
								
									ee6eb45d4b
								
							
						
					
					
						commit
						c14de06c86
					
				|  | @ -23,8 +23,9 @@ class FileOpen: | |||
|             os.makedirs(my_dir)  # 创建所有父文件夹 | ||||
|         # 读文件需要判断文件是否存在,不存在则创建 | ||||
|         if not os.path.exists(path): | ||||
|             open(path, mode, encoding) | ||||
|         return open(path, mode, encoding) | ||||
|             f = open(path, 'w', encoding) | ||||
|             f.close() | ||||
|         return open(path, mode=mode, encoding=encoding) | ||||
| 
 | ||||
|     @staticmethod | ||||
|     def write_able(path, mode='w', encoding=None): | ||||
|  | @ -33,7 +34,7 @@ class FileOpen: | |||
|         my_dir = os.path.dirname(path)  # 获得路径的目录 | ||||
|         if not os.path.exists(my_dir):  # 判断文件的所有父文件夹是否存在 | ||||
|             os.makedirs(my_dir)  # 创建所有父文件夹 | ||||
|         return open(path, mode, encoding) | ||||
|         return open(path, mode=mode, encoding=encoding) | ||||
| 
 | ||||
| 
 | ||||
| if __name__ == "__main__": | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue