Python3 字符串处理方法

List 拼接成字符串:

list = ['a','b','c']
','.join(list)

字符串内容替换:

str = 'abc123 / / 123'
str.replace('/',' ')

字符串正则替换:

import re
...

str = 'abc123 / / 123'
res.sub('/s+',' ',str)

正则提取:

content = "【hello】world"
match = re.match('【(.*)】', content, re.UNICODE)
if match:
    print match.group(1)

results matching ""

    No results matching ""