可以用了吧

This commit is contained in:
2024-10-21 23:40:19 +08:00
parent 84a24636f4
commit e2d484c6de
3 changed files with 7 additions and 6 deletions
+5 -4
View File
@@ -4,7 +4,8 @@ import aiofiles
async def write_file(
file_path: str,
content: str | bytes,
mode: str = "w"
mode: str = "w",
**kws,
):
"""
写入文件
@@ -13,11 +14,11 @@ async def write_file(
file_path: 文件路径
content: 内容
"""
async with aiofiles.open(file_path, mode) as f:
async with aiofiles.open(file_path, mode, **kws) as f:
await f.write(content)
async def read_file(file_path: str, mode: str = "r") -> str:
async def read_file(file_path: str, mode: str = "r", **kws) -> str:
"""
读取文件
Args:
@@ -25,5 +26,5 @@ async def read_file(file_path: str, mode: str = "r") -> str:
mode: 读取模式
Returns:
"""
async with aiofiles.open(file_path, mode) as f:
async with aiofiles.open(file_path, mode, **kws) as f:
return await f.read()