python print函数语法_Python print函数返回语法

我正在尝试使用print函数打印重新匹配但它作为打印的无效语法又回来了

python的版本是2.6.6import re

def word_replace(text, replace_dict):

rc = re.compile(r"[a-zA-Z]\w*")

def word_replace(text, replace_dict):

word = re.match("(0\w+)\W(0\w+)",lower()

print(word)

return replace_dict.get(word, word)

return rc.sub(translate, text)

old_text = open('1549963864952.xml').read()

replace_dict = {

"value" : 'new_value',

"value1" : 'new_value1',

"value2" : 'new_value2',

"value3" : 'new_value3'

} # {"Word to find" : 'Word to replace'}

output = word_replace(old_text, replace_dict)

f = open("1549963864952.xml", 'w') # File you want to write to

f.write(output) # Write to that file

print(output) # Check that it wrote

应该返回并打印word = re.match("(0\w+)\W(0\w+)",lower()的结果,但是我得到了以下错误:

^{pr2}$

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值