使用或

标准的正则表达式有小括号,但是python的没有

# -*- coding: utf-8 -*-

import sys
import re
import sys
reload(sys)
sys.setdefaultencoding( "utf-8" )

if __name__ == '__main__':
    print(sys.getdefaultencoding())
    str=u'你 好1'
    p = re.compile(r'\d|\s') #根据空格或者数字拆分字符串
    ss=p.split(str)
    print(ss[0])
    print(ss[1])
    print(ss[2])

相关文章:

  • 2021-11-13
  • 2021-10-09
  • 2021-09-28
  • 2022-12-23
  • 2021-11-21
  • 2021-05-23
  • 2021-12-24
  • 2021-09-17
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-09
  • 2021-12-07
  • 2022-12-23
  • 2022-01-14
相关资源
相似解决方案