我正在尝试解析变量“output”中的字符串“External-dep”并创建一个包含其值的字典列表,该变量存在于变量“output”中的多个位置..需要获取最新的。 .values to "External-dep" 总是整数.. 目前卡在下面我无法解析字符串 "External-dep",有人可以提供输入吗?
Master_change ="12345"
external_dep ={}
output="""change Ied13af85dec9128b6a715739b50ae2f33a92cf14
project: platform/data
branch: master
id: Ied13af85dec9128b6a715739b50ae2f33a92cf14
number: 12345
subject: code: test
owner:
name: danile david
email: gdavid@com.domain.com
username: gdavid
url: https://review-android.company.com/12345
createdOn: 2013-02-19 18:10:36 PST
lastUpdated: 2013-04-24 13:43:23 PDT
sortKey: 0024a01b0003dc6c
open: true
status: NEW
comments:
timestamp: 2013-04-22 15:20:17 PDT
reviewer:
name: danile david
email: gdavid@com.domain.com
username: gdavid
message: Patch Set 4:
External-dep: 311957
comments:
timestamp: 2013-04-24 13:43:23 PDT
reviewer:
name: danile david
email: gdavid@com.domain.com
username: gdavid
message: Patch Set 4:
External-dep: 312994 311957 312591
type: stats
rowCount: 1
runTimeMilliseconds: 4"""
for line in output :
if 'External-dep' in line:#make External-dep case-insensitive
print line
'''
预期输出:-
external_dep = {
'12345': ['312994','311957','312591']
}
'''