utils.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:niconico-tools 作者: mo-san 项目源码 文件源码
def load_cookies(cls, file_name=COOKIE_FILE_NAME):
        """
        ?????????????????????????????????

        :param str file_name:
        :rtype: dict | None
        """
        # Python 3.5??????????????
        # file_path = make_dir(Path.home() / file_name)
        #     return {line.split("\t")[0]: line.split("\t")[1]
        #             for line in file_path.read_text().split("\n")}
        try:
            file_path = join(expanduser("~"), file_name)
            with open(file_path, "r") as fd:
                return {line.split("\t")[0]: line.split("\t")[1].strip() for line in fd.readlines()}
        except (FileNotFoundError, EOFError):
            return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号