目录

Python文件处理与IO操作

nizhaohai 2025年01月05日 1 分钟阅读 736 次浏览 0 条评论

文件处理是编程中的常见任务。

文件读写

with open('file.txt', 'r', encoding='utf-8') as f:
    content = f.read()

路径处理

from pathlib import Path
p = Path('data') / 'file.txt'
p.exists()

JSON处理

import json
data = json.loads(json_string)
分享:
N
nizhaohai

相关文章

评论 (0)

暂无评论,来发表第一条评论吧!

发表评论