I have a file that contains many lines of plain text utf-8. For example, below, in Chinese.
PROCESS:类型:关爱积分[NOTIFY] 交易号:2012022900000109 订单号:W12022910079166 交易金额:0.01元 交易状态:true 2012-2-29 10:13:08
The file itself was saved in utf-8 format. file name xx.txt
here is my python code, env - python2.7
#coding: utf-8 import re pattern = re.compile(r'交易金额:(\d+)元') for line in open('xx.txt'): match = pattern.match(line.decode('utf-8')) if match: print match.group()
The problem is here - I did not get any results.
I want to get the decimal line from 交易金额:0.01元 , here 0.01 .
Why is this code not working? Can someone explain this to me, I had no idea.
castiel
source share