无法用tzinfo属性Pickle ldap3 datetime对象

2024-06-17 19:55:03 发布

您现在位置:Python中文网/ 问答频道 /正文

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()

给予。。。在

^{pr2}$

这看起来与ldap3.core.timezone.py...有关

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

不幸的是,我下一步要做的是。。。在用datetime对象本身进行pickle之前,是否应该解决这个问题?在

我不能用一个普通的Python日期时间对象重新创建它。在


Tags: orgimportoutputdatetimeserverconnectiondccn