我正在尝试读取输入文件并匹配包含“ToolVersionEdit”的行,然后根据“=”拆分并获取第二部分..我正在使用以下内容..没有得到所需的输出..我在哪里出错了?输入和预期输出如下
输入:
[BuildRequest]
BuildRequestVersion=4.4.21
BuildRequestType=Phone
BuildCommandComboBox=common/build/build.sh tz:A8064AAAAANAAT140029.1 tz_bid=AAAAANAA wcnss:A8064AAAAANAAW120072.1 wcnss_bid=SCAQBAF lpass:A8064AAAAANAZL140106.1 boot_9x15:M9615ACETRMAAB12171.1 boot_9x15_bid=ACEHRMAA rpm:A8064AAAAANAAR1100153.1 rpm_bid=AAAAANAAR modem_9x15:M9615ACEFWTAAM4010223.1 modem_9x15_bid=ACEFWTAA apps_9x15:M9615AFEHRMAA2745.1 apps_9x15_bid=AFEHRMAA rpm_9x15:M9615ACETRMAAR1100159.4 rpm_9x15_bid=AAAAANAAR boot:A8064AAAAANAAB12171.1 boot_bid=AAAAANAA lpass_9x15:M9615ACETRMAZL140105.3 apps:A8064AAAAANLGA2214074.1 dsps:A8064AAAAANAAS150007.1 dsps_bid=DSPSBLD
ToolVersionEdit=1.6.21
CheckSumCheckBox=0
PurposeEdit=
[BuildRequestComments]
LineCount=0
预期输出:-1.6.21
import re
import sys
file = "C:\Dropbox\Reference.brf"
lines = open(file ,'r').readlines()
for line in lines:
if 'ToolVersionEdit' in line:
line = line.strip('=')[1]
print line