我在将简单字符串输出比较到if语句时遇到了问题,我的假设可能在pefile模块输出中,因为我使用pefile python模块,代码如下所示:
import pefile
for filename in glob.iglob('C:\Documents and Settings\User\Desktop\samples\*'):
if pe.get_section_by_rva(pe.OPTIONAL_HEADER.AddressOfEntryPoint) is not None:
a = pe.get_section_by_rva(pe.OPTIONAL_HEADER.AddressOfEntryPoint)
if '.text' is a.Name :
print 'ok'
else:
print 'not ok'
以上代码的所有结果均为not ok
我的意图是当a.Name的结果是.text时,输出正常或不正常,如果你实际使用print a.Name
,输出将是:
.code .text .text .text .text .text UPX0 qyjaaari
在文本文件和
中.code
.text
.text
.text
.text
.text
UPX0
qyjaaari
和cmd一样,是否需要解释?
PS:我已经尝试在if语句中使用==
比较器并仍然打印不正确