对str类型数据进行split操作如下: s = 'abc\ndef' s.split('\n')['abc', 'def'] 对bytes类型数据进行split操作如下: b = b'abc\ndef' b.split(b'\n')[b'abc', b'def'] 测试Python版本:3.6.5 以上这篇对python的bytes类型
对str类型数据进行split操作如下:
>>> s = 'abc
def'
>>> s.split('
')
['abc', 'def']
对bytes类型数据进行split操作如下:
>>> b = b'abc def' >>> b.split(b' ') [b'abc', b'def']
测试Python版本:3.6.5
以上这篇对python的bytes类型数据split分割切片方法就是小编分享给大家的全部内容了,希望能给大家一个参考。

发表评论