false未定义

时间:2014-01-22 20:17:47

标签: python python-2.7

我关注“https://www.mandiant.com/blog/parsing-registry-hives-python/”。

在代码下面运行时:

f = open("SAMPLE1.DAT")
buf = f.read()
regf = RegistryParse.REGFBlock(buf, 0, false) 

for HBIN in regf.hbins():
    for cell in HBIN.cells():
        if cell.is_free():
            print "Unallocated cell at offset 0x%x" % (cell.offset())

我收到错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'false' is not defined

原因是什么?

现在,它来了:

Traceback (most recent call last):
  File "mig.py", line 11, in <module>
    regf = RegistryParse.REGFBlock(buf, 0, False) 
  File "/usr/local/lib/python2.7/dist-packages/Registry/RegistryParse.py", line 236, in         __init__
    raise ParseException("Invalid REGF ID")
Registry.RegistryParse.ParseException: Registry Parse Exception(Invalid REGF ID)

3 个答案:

答案 0 :(得分:9)

False应该在Python中大写:

regf = RegistryParse.REGFBlock(buf, 0, False)

请记住,Python区分大小写。

答案 1 :(得分:5)

Python区分大小写。 False!= false!= fAlSe

答案 2 :(得分:2)

False与大写F

一起使用
regf = RegistryParse.REGFBlock(buf, 0, False) 

不幸的是,那篇博文的拼写错误。