vv.py 文件源码

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

项目:pyfeedback 作者: d120 项目源码 文件源码
def replace_first_line(file, replacement):
    # suppress a type error which was confusing
    if type(file) is not InMemoryUploadedFile:
        with open(file, 'r', encoding='iso-8859-1') as f:
            data = f.readlines()

        if "!DOCTYPE" not in data[0]:
            data[0] = replacement
            with open(file, 'w') as f:
                f.writelines(data)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号