Why is there a NameError: name [variable] is not defined in this list variable?
本问题已经有最佳答案,请猛点这里访问。
每当我试图运行代码时,都会出现这个错误。我相信这两个列表的
错误:
1 2 3 | File"C:/Users/Asus/Google Drive/Sun Gleam & Fine Works/System Improvement/Accounting/Voucher Reports/Voucher Reports", line 12, in <module> summary_name[i] = data_listofaccounts['Account Name'] NameError: name 'summary_name' is not defined |
代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import pandas as pd import matplotlib.pyplot as plt entries_csv ="C:\\Users\\Asus\\Desktop\\Entries.csv" listofaccounts_csv ="C:\\Users\\Asus\\Desktop\\List of Accounts.csv" data_entries = pd.read_csv(entries_csv) data_listofaccounts = pd.read_csv(listofaccounts_csv) i = 0 for account_name in data_listofaccounts['Account Name']: summary_name[i] = data_listofaccounts['Account Name'] for debit_account in data_entries['DEBIT ACCOUNT']: if account_name == debit_account: summary[i] += data_entries['DEBIT AMOUNT'] i += 1 for p in range(i): print(summary[p]) print(summary_name[p]) |
这个
1 | summary_name[i] |
假设已经有了
因此,你必须首先确定
ZZU1
管
1 | summary_name = ("I","am","a","tuple") |
或弦乐
1 | summary_name ="I am a string." |
所有这些合金读取使用
自从你想使用写作存取,你必须确定一个允许
1 | summary_name = [None] * 100 |
只有在这之后,你才能确定这张名单的内容。