preferences.py 文件源码

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

项目:software-boutique 作者: ubuntu-mate 项目源码 文件源码
def save_to_disk(self):
        """
        Commit the data from memory to disk.
        Returns True or False depending on success/failure.
        """
        # Create file if it doesn't exist.
        if not os.path.exists(self.file_path):
            open(self.file_path, "w").close()

        # Write new data to specified file.
        if os.access(self.file_path, os.W_OK):
            f = open(self.file_path, "w+")
            f.write(json.dumps(self.data, sort_keys=True, indent=4))
            f.close()
            return True
        else:
            return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号