__init__.py 文件源码

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

项目:mt7687-serial-uploader 作者: will127534 项目源码 文件源码
def calc_checksum(self, data, checksum=0):
        '''
        Calculate the checksum for a given block of data, can also be used to
        update a checksum.

            >>> csum = modem.calc_checksum('hello')
            >>> csum = modem.calc_checksum('world', csum)
            >>> hex(csum)
            '0x3c'

        '''
        if platform.python_version_tuple() >= ('3', '0', '0'):
            return (sum(data) + checksum) % 256
        else:
            return (sum(map(ord, data)) + checksum) % 256
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号