dic={'el1': [1,2,3], 'el2': 'Hello!'}
dic['el1']
x=str(100000)
time=170000000
sec='ALRS'
"SELECT * FROM order_log WHERE \"TIME\"<="+str(time)+" AND\"SECCODE\"='"+sec+"'"
import matplotlib.pyplot as plt
plt.plot(x['LOB'].index,x['LOB']['B'], x['LOB'].index,x['LOB']['S'])
# plt.bar(x['LOB'].index,x['LOB']['S'])
TypeError: string indices must be integers
为什么返回字符串索引必须是整数?
答案 0 :(得分:0)
Python要求嵌套语句,以便知道控制流的结构。 with
块需要知道何时自动关闭文件,因此下一条语句需要缩进。试试这个:
with open('C:/Users/Public/order_log.sql','r') as query:
data=pd.read_sql_query(query.read(),conn) data.head(10)