re.findall python中的正则表达式问题

时间:2017-05-11 13:33:43

标签: python regex

当我在ipython下运行以下命令时;

>>> s = '{\f226 Please press the} "{\f226 Input}'
>>> re.findall(r'\{\f226.*?\}',s)
['{\x0c226 Please press the}', '{\x0c226 Input}']

当我在python脚本下运行相同的命令时,它给了我一个空列表。我使用相同的Python版本。

import sys, codecs, re

if __name__ == "__main__":
        f = sys.argv[1]
        tn = f + ".fixed"
        f = codecs.open(f, encoding="utf-8").read()

        brackets = re.findall(r'\{\f226.*?\}', f)
        nonbrackets = re.findall(r'\{\f226(.*?)\}', f)

        print brackets

结果是[]。我该怎么办?

0 个答案:

没有答案
相关问题