【发布时间】:2015-10-14 14:28:12
【问题描述】:
我需要将配置列表 (req_config) 与预先存在的 (masterList) 列表进行比较。
我遇到了一些逻辑错误,因为代码在某些配置中运行良好,而在其他配置中给出了错误的输出。请帮忙。
import re
masterList = ['MEMSize', 'conservativeRasEn', 'Height', 'multipleBatch', 'Width', 'dumpAllRegsAtFinish', 'ProtectCtl', 'isdumpEnabled','vh0', 'vw0','lEnable', 'WaveSize','maxLevel','pmVer', 'cSwitchEn', 'disablePreempt', 'disablePreemptInPass', 'ctxSwQueryEn', 'forceEnable', 'enableDebug', '5ErrEn', 'ErrorEn']
req_config = ['MEMSize', 'Height', 'Width', 'isdumpEnabled', 'vh0', 'vw0', 'lEnable', 'WaveSize', 'maxLevel', 'Information', 'ConservativeRasEn']
for config in req_config:
if any(config in s for s in masterList):
print "Config matching: ", config
else:
print "No match for: ", config
预期输出:
Config matching: MEMSize
Config matching: Height
Config matching: Width
Config matching: isdumpEnabled
Config matching: vh0
Config matching: vw0
Config matching: lEnable
Config matching: WaveSize
Config matching: maxLevel
No match for: Information
Config matching: ConservativeRasEn
电流输出:
Config matching: MEMSize
Config matching: Height
Config matching: Width
Config matching: isdumpEnabled
Config matching: vh0
Config matching: vw0
Config matching: lEnable
Config matching: WaveSize
Config matching: maxLevel
No match for: Information
No match for: ConservativeRasEn
【问题讨论】:
-
conservativeRasEn!=ConservativeRasEn(通知信大小写) -
谢谢。我可以得到错误。我可以问你,如何使我的比较不区分大小写。这是实际的要求。