- 論壇徽章:
- 0
|
原帖由 xiaoyu9805119 于 2009-2-27 10:28 發(fā)表 ![]()
>>> print re.sub("(.*) (.*)", r"\2 \1", "hello smallfish"
smallfish hello
調(diào)換匹配的
>>> print re.sub("(.*) (.*)", r"hi \2", "hello smallfish"
hi smallfish
直接修改的
看到了把,是不是 ...
<book id="1" fullname="/home/napleon/AF_yyy.so" name="yyy"></book>
>>> print re.sub("(.*)(.*)",r"\2\1","hello smallfish"
hello smallfish
>>> print re.sub("(.*)(.*)",r"hi\1","hello smallfish"
hihello smallfish
>>> print re.sub("(.*)(.*)",r"\1\2","hello smallfish"
hello smallfish
>>> print re.sub("(.*)(.*)",r"\2\1","hello smallfish"
hello smallfish
為什么我的換不了? |
|