Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 无法使用tzinfo属性Pickle ldap3 datetime对象_Python_Pickle_Python Datetime_Ldap3 - Fatal编程技术网

Python 无法使用tzinfo属性Pickle ldap3 datetime对象

Python 无法使用tzinfo属性Pickle ldap3 datetime对象,python,pickle,python-datetime,ldap3,Python,Pickle,Python Datetime,Ldap3,给 from ldap3 import Server, Connection, ALL import pickle server = Server('ipa.demo1.freeipa.org', get_info=ALL) conn = Connection(server, 'uid=admin,cn=users,cn=accounts,dc=demo1,dc=freeipa,dc=org', 'Secret123', auto_bind=True) entries = conn.exten

from ldap3 import Server, Connection, ALL
import pickle

server = Server('ipa.demo1.freeipa.org', get_info=ALL)
conn = Connection(server, 'uid=admin,cn=users,cn=accounts,dc=demo1,dc=freeipa,dc=org', 'Secret123', auto_bind=True)
entries = conn.extend.standard.paged_search('dc=demo1,dc=freeipa,dc=org', '(objectClass=person)', attributes=['cn', 'givenName', 'createtimestamp'], paged_size=5)

testlist = []

for entry in entries:
    testlist.append(entry)

output = open('data.pkl', 'wb')
pickle.dump(testlist, output)
output.close()

pkl_file = open('data.pkl', 'rb')
test2 = pickle.load(pkl_file)

pkl_file.close()
C:\Python36\python.exe C:/Users/xxxxx/Dropbox/xxx/Work/python/CEDAR/ldaptest.py
回溯(最近一次呼叫最后一次):
文件“C:/Users/xxxxx/Dropbox/xxx/Work/Python/CEDAR/ldaptest.py”,第20行,在
test2=pickle.load(pkl_文件)
TypeError:\uuuu init\uuuu()缺少2个必需的位置参数:“偏移量”和“名称”
进程已完成,退出代码为1
这似乎与

createtimestamp
属性看起来是
datetime.datetime(2017,6,18,11,13,38,tzinfo=OffsetTzInfo(offset=0,name='UTC'))

不幸的是,这就是我不知道下一步该做什么的地方。。。这是不是在处理datetime对象本身之前应该解决的问题


我无法使用常规的Python datetime对象重新创建此对象。

请尝试在
\uuuu主命名空间中导入
tzinfo
。如果这对你没有帮助,你必须先从
createtimestamp
中删除
tzinfo
,然后再在depickelinf后选择并重新评估它。我相信这是相关的
C:\Python36\python.exe C:/Users/xxxxx/Dropbox/xxx/Work/Python/CEDAR/ldaptest.py
Traceback (most recent call last):
  File "C:/Users/xxxxx/Dropbox/xxx/Work/Python/CEDAR/ldaptest.py", line 20, in <module>
    test2 = pickle.load(pkl_file)
TypeError: __init__() missing 2 required positional arguments: 'offset' and 'name'

Process finished with exit code 1