我正在尝试运行此python文件,当我尝试在终端中运行此文件或直接执行(双击文件)时,我是python的新编程人员 我收到此错误:
File "C:\Users\benja\code\orig-master\data_new_score.py", line 106
l.append(info_cc_d w(loan_id).values())
^
我的文件
import pandas as pd
import yaml
import MySQLdb
import datetime
loan_ids = ['10003395','10008588','10008591','10008611','10008638','10008653','10008665','10008674','10008675','10013191','10003674','10003689','10003692','10003711','10003716','10003722','10003728','10003733','10003739','10003776','10003785','10003820','10003822','10003827','10003309','10003316','10003327','10003348','10005950']
columns = info_cc_dw('10003391').keys()
l=[info_cc_dw('10003391').values()]
for loan_id in loan_ids:
l.append(info_cc_d w(loan_id).values())
data = pd.DataFrame(l,columns=columns)
data.to_csv('test_dw.csv')
答案 0 :(得分:0)
尝试一下:
import pandas as pd
import yaml
import MySQLdb
import datetime
loan_ids = ['10003395','10008588','10008591','10008611','10008638','10008653','10008665','10008674','10008675','10013191','10003674','10003689','10003692','10003711','10003716','10003722','10003728','10003733','10003739','10003776','10003785','10003820','10003822','10003827','10003309','10003316','10003327','10003348','10005950']
columns = info_cc_dw('10003391').keys()
l=[info_cc_dw('10003391').values()]
for loan_id in loan_ids:
l.append(info_cc_d w(loan_id).values())
data = pd.DataFrame(l,columns=columns)
data.to_csv('test_dw.csv')
如您所见,我在您的 for循环之后缩进了一行。这只是python语法的一部分。