-5

我有一个Python字典如下

dictvvalue={'a':'1','b':'2','c':{'d':'5','e':'6'}}

我的目的是保存这个 Python 字典以供另一个 Python 脚本使用。

我必须将此字典作为字典而不是字符串加载到其他脚本中。

请帮忙

谢谢

4

1 回答 1

2

As Generic alluded to, you must encode it as a bytestring before you can persist it, and then decode it when reading in. The common ways to do this in Python are pickling (via pickle/cPickle), JSON (via json), or YAML (via PyYAML).

于 2012-07-25T04:42:40.403 回答