我试图从下面的LDIF示例文件中分析数据。我只想在csv文件中写入'LoginID'和'mail'参数的值。在
dn: uid=123456789012345,ou=Students,o=system.edu,o=system
LoginId: 0012345
mail: test1@test.edu
dn: uid=543210987654321,ou=Students,o=system.edu,o=system
LoginId: 0067890
mail: test2@test.edu
下面是我在编译时遇到问题的代码
^{pr2}$当我编译代码时,我得到一个错误
Traceback (most recent call last):
File "LDIFExtract.py", line 14, in <module>
ParseRecords(infile,csv_writer).parse()
File "/usr/lib/python2.7/dist-packages/ldif.py", line 345, in parse
self._line = self._input_file.readline()
AttributeError: ParseRecords instance has no attribute '_input_file'
感谢任何帮助解决这个问题。在
谢谢
您重写了从中继承的类的
__init__
函数(LDIFParser),它可能包含类似self._input_file = infile
的内容。您可以通过在构造函数中调用LDIFParser.__init__(self, <the arguments that it would use>)
或首先不重写构造函数来在类内部运行构造函数命令。在相关问题 更多 >
编程相关推荐