相关疑难解决方法(0)

为什么不添加二元泡菜?

我知道这并不是打算如何使用pickle模块,但我认为这会起作用.我正在使用Python 3.1.2

这是后台代码:

import pickle

FILEPATH='/tmp/tempfile'

class HistoryFile():
    """
    Persistent store of a history file  
    Each line should be a separate Python object
    Usually, pickle is used to make a file for each object,
        but here, I'm trying to use the append mode of writing a file to store a sequence
    """

    def validate(self, obj):
        """
        Returns whether or not obj is the right Pythonic object
        """
        return True

    def add(self, obj):
        if self.validate(obj):
            with open(FILEPATH, mode='ba') as f:    # …
Run Code Online (Sandbox Code Playgroud)

python pickle

3
推荐指数
1
解决办法
5915
查看次数

标签 统计

pickle ×1

python ×1