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