在<模块>列表中= pickle.load(pkl_file)EOF错误:显示输入超出限制

时间:2018-08-20 12:57:27

标签: input import export pickle eoferror

这是我的代码,用于医学日期排序系统。

问题是由于正在读取文件并将其加载到列表中,因此标题中出现错误,我尝试创建一个异常,但是每次我在任何地方告诉python告诉我语法无效时,我都没有知道该怎么做,我知道这不可能是我正在使用wb,因为我正在使用rb加载数据。我将来会用tkinter

列表= []

x = 5 对于范围为(1,10)的x:

from tkinter import *
import time
import datetime
import pickle
import pprint, pickle
output = open('data.pkl', 'wb')    

pkl_file = open('data.pkl', 'rb')
list = pickle.load(pkl_file)
pkl_file.close()

time.sleep(0.5)

date1 = datetime.date.today()
print(date1)
month = int(input('please enter the month (E.G 08) :'))
time.sleep(0.5)

month1 = month+3
if date1 in list:
    print(list)
    print('there is an out of date item')
    print('to search for this item press Ctrl+F and type the date into the search box, then click ok')
    option3 = int(input('would you like to remove it from the database? 1/0'))
    if option3 == y:
        print('copy the element needing to be removed from the list(the highlighted element)and paste it as the next answer')
        removing = input('paste here: ')
        list.remove(removing)
        print('It has been succesfully removed')
        output = open('data.pkl', 'wb')    
        pickle.dump(list, output) 

elif month1 in list:
    print('there is a soon to be out of date item')
    print('to search for this item press Ctrl+F and type', (month1), 'into the search box, then click ok')        

output = open('data.pkl', 'wb')

pickle.dump(list, output)

time.sleep(1)

option1 = int(input('would you like to add a medicine(1); check all medicines on the system(2);re-run expiry check(3); remove a medicine(4); or restart(5): '))


if option1 == 1:
    option2 = int(input('would you like to enter one (1) or a mass amount (10 packs) (2)? :'))

    if option2 == 1:
        item = input('enter the name of the medicine; what drawer number it is in; dosage; amount of tablets/other; and the date (E.G 10/10/10) :')
        list.append(item)
        output = open('data.pkl', 'wb')    
        pickle.dump(list, output)
    elif option2 == 2:
        item = input('enter the name of the medicine; what drawer number it is in; dosage; amount of tablets/other; the date and amout (E.G 1010-10-10) :')
        list.append(item)
        output = open('data.pkl', 'wb')    
        pickle.dump(list, output) 
        item = input('enter the name of the medicine; what drawer number it is in; dosage; amount of tablets/other; the date and amout (E.G 1010-10-10) :')
        list.append(item)
        output = open('data.pkl', 'wb')    
        pickle.dump(list, output) 
        item = input('enter the name of the medicine; what drawer number it is in; dosage; amount of tablets/other; the date and amout (E.G 1010-10-10) :')
        list.append(item)
        output = open('data.pkl', 'wb')    
        pickle.dump(list, output) 
        item = input('enter the name of the medicine; what drawer number it is in; dosage; amount of tablets/other; the date and amout (E.G 1010-10-10) :')
        list.append(item)
        output = open('data.pkl', 'wb')    
        pickle.dump(list, output) 
        item = input('enter the name of the medicine; what drawer number it is in; dosage; amount of tablets/other; the date and amout (E.G 1010-10-10) :')
        list.append(item)
        output = open('data.pkl', 'wb')    
        pickle.dump(list, output) 
        item = input('enter the name of the medicine; what drawer number it is in; dosage; amount of tablets/other; the date and amout (E.G 1010-10-10) :')
        list.append(item)
        output = open('data.pkl', 'wb')    
        pickle.dump(list, output) 
        item = input('enter the name of the medicine; what drawer number it is in; dosage; amount of tablets/other; the date and amout (E.G 1010-10-10) :')
        list.append(item)
        output = open('data.pkl', 'wb')    
        pickle.dump(list, output) 
        item = input('enter the name of the medicine; what drawer number it is in; dosage; amount of tablets/other; the date and amout (E.G 1010-10-10) :')
        list.append(item)
        output = open('data.pkl', 'wb')    
        pickle.dump(list, output) 
        item = input('enter the name of the medicine; what drawer number it is in; dosage; amount of tablets/other; the date and amout (E.G 1010-10-10) :')
        list.append(item)
        output = open('data.pkl', 'wb')    
        pickle.dump(list, output) 
        item = input('enter the name of the medicine; what drawer number it is in; dosage; amount of tablets/other; the date and amout (E.G 1010-10-10) :')
        list.append(item)
        output = open('data.pkl', 'wb')    
        pickle.dump(list, output)            
elif option1 == 2:
    print(list)

elif option1 == 3:
    if date1 in list:
        print(list)
        print('there is an out of date item')
        print('to search for this item press Ctrl+F and type the date into the search box, then click ok')
        option3 = int(input('would you like to remove it from the database? 1/0'))
        if option3 == 1:
            print('copy the element needing to be removed from the list(the highlighted element)and paste it as the next answer')
            removing = input('paste here: ')
            list.remove(removing)
            print('It has been succesfully removed')
            output = open('data.pkl', 'wb')    
            pickle.dump(list, output) 
        elif option3 == 0:
            print("ok medicine will not be removed")                
    elif month1 in list:
        print('there is a soon to be out of date item')
        print('to search for this item press Ctrl+F and type', (month1), 'into the search box, then click ok')        

elif option1 == 4:
    print(list)
    print('to search for the item you would like to remove press Ctrl+F and type the medicine name into the search box, then click ok, copy the element you would like to remove and')
    removing = input("paste it here: ")
    list.remove(removing)
    output = open('data.pkl', 'wb')    
    pickle.dump(list, output)     
elif option1 == 5:
    print('restarting')
    time.sleep(0.5)
    print('...')

0 个答案:

没有答案