0
def append_customer(file_variable, fields):
"""
-------------------------------------------------------
Appends a customer record to a sequential file.
-------------------------------------------------------
Preconditions:
file_variable - the file to search (file)
fields - data to append to the file (list)
Postconditions:
The data in fields are appended to file_variable.
-------------------------------------------------------
"""
if os.path.exists(file_variable) == True:
file = open(file_variable, "w", encoding="utf-8")
file.seek(0)
print("{0}".format(fields), file=file_variable)
file.close()
return
的已定义这是一个功能我写的数据添加到文件中,唯一的错误在于显然是“file_variable未定义” ......即使它清楚地由函数定义。我不知道为什么会发生此错误。未定义变量的错误,虽然它在功能上
这是你的缩进吗? –
向我们展示您调用该功能的位置。请[mcve]。 – Kevin