Skip to content

请教一下代码中的一个小问题 #1

@supersu097

Description

@supersu097
   @staticmethod
    def decryptM4s(target_path: str, output_path: str, bufsize: int = 256 * 1024 * 1024) -> None:
        assert bufsize > 0
        with open(target_path, 'rb') as target_file:
            header = target_file.read(32)
            new_header = header.replace(b'000000000', b'')
            new_header = new_header.replace(b'$', b' ')
            new_header = new_header.replace(b'avc1', b'')
            with open(output_path, 'wb') as output_file:
                output_file.write(new_header)
                i = target_file.read(bufsize)
                while i:
                    output_file.write(i)
                    i = target_file.read(bufsize)

请问一下上述代码中的for循环中的output_file.write(i)语句不会导致前面被replace清洗掉的脏数据又被重新覆盖成脏数据么?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions