擅长:python、mysql、java
<p>这听起来像是用一个方形的木桩来装圆孔。如何使用pickle来pickle参数,并取消pickle来重建<code>reverand.Thomas.Bayes</code>对象?在</p>
<pre><code>>>> from collections import namedtuple
>>> ArgList = namedtuple('your', 'arguments', 'for', 'the', 'reverand')
>>> def pickle_rtb(n):
... return pickle.dumps(ArgList(*n.args))
...
>>> def unpickle_rtb(s):
... return reverand.Thomas.Bayes(*pickle.loads(s))
...
>>> s = pickle_rtb(reverand.Thomas.Bayes(1, 2, 3, 4, 5)) # note arguments are a guess
>>> rtb = unpickle_norm(s)
</code></pre>
<p>灵感来自于<a href="https://stackoverflow.com/questions/14235693/how-to-pickle-a-scipy-stats-distribution-cant-pickle-instancemethod-objects">this</a>SO问题。在</p>