美文网首页
day009 作业1 7-26

day009 作业1 7-26

作者: Yehao_ | 来源:发表于2018-07-26 20:08 被阅读0次
import json


def read_file(path):
    """
    Read a file.
    :param path:
    :return:
    """
    with open(path, 'r', encoding='utf-8') as f:
        f.read()

def rewrite_file(path, content):
    """
    Cover the origin file with content that commit .
    :param path: where file locate at
    :param content:content that will write into file
    :return:
    """
    with open(path, 'w', encoding='utf-8') as f:
        f.write(content)

def write_file(path, content):
    """
    Insert content after the origin file .
    :param path: where file locate at
    :param content: content that will write into file
    :return:
    """
    with open(path, 'a', encoding='utf-8') as f:
        f.write(content)

def read_binary_file(path):
    """
    Read a binary file.
    :param path:
    :return:
    """

    with open(path, 'rb', encoding='utf-8') as f:
        f.read()

def rewrite_binary_file(path, content):
    """
    Cover the origin binary file with content that commit .
    :param path: where file locate at
    :param content:content that will write into file
    :return:
    """
    with open(path, 'wb', encoding='utf-8') as f:
        f.write(content)

def read_json_file(path):
    """
    Read a .json file.
    :param path:
    :return:
    """
    with open(path, 'r', encoding='utf-8') as f:
        json.load(f)

def write_json_file(path, content):
    """
    Cover the .json file with content.
    :param path:
    :param content:
    :return:
    """
    with open(path, 'w', encoding='utf-8') as f:
        json.dump(content, f)

def convert_json_to_python(content):
    json.loads(content, encoding='utf-8')

def convert_python_to_json(content):
    json.dumps(content)

相关文章

  • day009 作业1 7-26

  • day009 笔记 7-26

    模块 模块是一个包含所有你定义的函数和变量的文件,其后缀名是.py。即一个.py文件就是一个模块。模块可以被别的程...

  • BM运营官-【体验感】DAY009-by Bella

    DAY009 by Bella作业内容: 参加过哪些让你感觉体验不错的线下活动?说说让你学习到的地方有哪些? 0....

  • 2018-04-04浮动布局

    Day009,30min float:left/right, clear:both

  • 走心服务,流程培训

    7-26日作业 第二课第二次作业: 你要给你的深度信任用户提供哪些价值服务?(因为深度信任用户是能够给我们带来很大...

  • Day009 - GooPin-1

    营造和谐的画面,需要元素的统一。包括字体、字号、粗细、间距、用色、对齐。。。需要把相同的元素重复使用。从用户接受信...

  • 第四章

    7-26第四章1/2 阅读内容: 4.1什么是情绪? 4.2影响情绪表达的因素 导读问题: 1什么是情绪智商? 我...

  • Day009

    Last night I saw a movie called “COCO”.The man name’s Mig...

  • Day009

    Today I will visit a principal from ShenZhen and a profes...

  • DAY009

    Last night we had a very wonderful party. It is so happy ...

网友评论

      本文标题:day009 作业1 7-26

      本文链接:https://www.haomeiwen.com/subject/rbkimftx.html