【问题标题】:I have following problem. Please can anyone explain what is problem? [duplicate]我有以下问题。请任何人都可以解释什么是问题? [复制]
【发布时间】:2020-04-01 21:50:05
【问题描述】:
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

为什么返回字符串索引必须是整数?

【问题讨论】:

  • 尝试缩进第二行

标签: python postgresql jupyter-notebook


【解决方案1】:

Python 要求语句是嵌套的,以便知道控制流的结构。 with 块需要知道何时自动关闭文件,因此下一条语句需要缩进。试试这个:

with open('C:/Users/Public/order_log.sql','r') as query:
    data=pd.read_sql_query(query.read(),conn) data.head(10)

【讨论】:

  • 感谢您的回答。它确实有效)
猜你喜欢
  • 1970-01-01
  • 2017-05-09
  • 2023-01-16
  • 2016-05-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-06-03
相关资源
最近更新 更多