Why do I get “Pickle - EOFError: Ran out of input” reading an empty file?

前端 未结 7 2458
小鲜肉
小鲜肉 2020-11-28 05:55

I am getting an interesting error while trying to use Unpickler.load(), here is the source code:

open(target, \'a\').close()
scores = {};
with o         


        
7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-28 06:44

    if path.exists(Score_file):
          try : 
             with open(Score_file , "rb") as prev_Scr:
    
                return Unpickler(prev_Scr).load()
    
        except EOFError : 
    
            return dict() 
    

提交回复
热议问题