Reading from a file using pickle and for loop in python

后端 未结 1 980
别跟我提以往
别跟我提以往 2021-02-08 00:50

I have a file in which I have dumped a huge number of lists.Now I want to load this file into memory and use the data inside it.I tried to load my file using the \"load\" method

相关标签:
1条回答
  • 2021-02-08 01:36

    How about this:

    lists = []
    infile = open('yourfilename.pickle', 'r')
    while 1:
        try:
            lists.append(pickle.load(infile))
        except (EOFError, UnpicklingError):
            break
    infile.close()
    
    0 讨论(0)
提交回复
热议问题