gpt4 book ai didi

python - 当我运行我的函数 :- SyntaxError: unexpected EOF while parsing 时,我不断收到此错误

转载 作者:太空宇宙 更新时间:2023-11-04 01:05:45 28 4
gpt4 key购买 nike

我不知道为什么我在运行 addItem() 时收到一条错误消息:

SyntaxError: unexpected EOF while parsing

我关闭了对文件的所有读写操作,并且我正在使用 raw_input 函数。我认为我的 readfrom() 函数有问题,但我不知 Prop 体是什么。

import ast


def writeTo():

itemx=",".join(map(str,itemx))
with open("ListItemz.txt","a") as filewrite:
filewrite.write(str(itemx)+"\n")
filewrite.close()

def readfrom():

fileread=open("ListItemz.txt","r")
fr=fileread.readlines()
fr=fr[len(fr)-1]
itemx=list(ast.literal_eval(fr))
fileread.close()

itemx=[]

def addItem():

global itemx
if itemx==[]:
itemx=[]
else:
"""
about to read file:
"""
readfrom()
dowhile="y"
while dowhile =="y":
item=raw_input("please enter item discription, or barcode No. ")
if itemx!=[]:
for y in itemx:
if item==y[0] or item==y[1]:
raise TypeError("This Item is already added")
case=int(raw_input("Enter how much holds in one (1) case: "))
caseNo=int(raw_input("how many cases are there? "))
for i in stockList():
if item==i[1] or item==i[0]:
itemx+=[[i[0],i[1],case,caseNo]]
print "ITEM ADDED"
dowhile=raw_input("Do you want to add another?(Y/N) ")
"""
about to write itemx to a file:
"""
writeTo()
return itemx

最佳答案

我写入的文件 (ListItemz.txt) 很复杂,所以我只是删除了一些东西并重新开始。

关于python - 当我运行我的函数 :- SyntaxError: unexpected EOF while parsing 时,我不断收到此错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30539564/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com