python bytes类型去除尾部字节

    by = b'\x01\x02'
    print(by)
    by = by.rstrip()
    print(by)
    by = by.rstrip(chr(2).encode())
    print(by)

b'\x01\x02'
b'\x01\x02'
b'\x01'

posted @ 2018-10-31 08:36  xiaodebing  阅读(2749)  评论(0编辑  收藏  举报