core.fs
--- 文件快捷处理器¶
-
exception
core.fs.
InvalidPath
¶ 基类:
tornado.web.HTTPError
抛出非法Http异常错误
-
core.fs.
check_join
(root_path: str, *args) → str¶ 检查合并后的路径是否在root_path当中,如果超出抛出异常
参数: - root_path -- 根路径
- args -- 路径块集合
返回: 合并后的绝对路径
-
core.fs.
read
(path: str, encoding: str = 'utf-8') → str¶ 读取文件返回字符串
参数: - path -- 文件路径
- encoding -- 编码方式
返回: 读取所有字符串
-
core.fs.
read_bytes
(path: str) → bytes¶ 读取文件返回bytes
参数: path -- 文件路径 返回: 读取所有字符串
-
core.fs.
require
(path: str, encoding: str = 'utf-8') → Dict[str, Any]¶ 有时你可能只是需要从文件中读取到json数据,这是require函数将根据 获取到的path,返回dict对象,相当方便,该函数同样类似于json.load
参数: - path -- json文件路径
- encoding -- 编码方式
返回: dict
-
core.fs.
safe_join
(*args) → str¶ 合并给定路径成为一个绝对路径,如果某个子路径块超出父路径就会抛出异常
参数: args -- 路径块集合 返回: 合并后的绝对路径
-
core.fs.
write
(path: str, data: str, encoding: str = 'utf-8') → NoReturn¶ 将字符串写入文件当中
参数: - path -- 文件路径
- data -- 写入的字符串数据
- encoding -- 编码方式
返回:
-
core.fs.
write_bytes
(path: str, data: bytes) → NoReturn¶ 将bytes写入文件当中
参数: - path -- 文件路径
- data -- 写入的字符串数据
返回: