Python 正则表达式

字符串替换

# coding=utf8
import re

p = re.compile("world")
s = "hello world, i love world, thx world."
b = p.sub("python", s)
print b

'''
输出:

hello python, i love python, thx python.
'''

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

开始在上面输入您的搜索词,然后按回车进行搜索。按ESC取消。

返回顶部