Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Python在交互式代理中的列表中获取permID_Python - Fatal编程技术网

使用Python在交互式代理中的列表中获取permID

使用Python在交互式代理中的列表中获取permID,python,Python,此代码: open_trades = ib.trades() #Interactive Brokers function for i in range(0,len(open_trades)): print(open_trades[i].orderStatus 打印OrderStatusstatus='Submitted',剩余=1000.0,permId=1036207528,clientId=1 现在我怎么才能拿到许可证 答案应该是这样的我也尝试了很多其他的方法: open_tra

此代码:

open_trades = ib.trades() #Interactive Brokers function
for i in range(0,len(open_trades)):
     print(open_trades[i].orderStatus
打印OrderStatusstatus='Submitted',剩余=1000.0,permId=1036207528,clientId=1

现在我怎么才能拿到许可证

答案应该是这样的我也尝试了很多其他的方法:

open_trades[i].orderStatus.permID #no attribute error
open_trades[i].orderStatus.OrderStatus.permID #no attribute error
open_trades[i].orderStatus[0].permID #gets error 'OrderStatus' object does not support indexing
最后一次尝试很可能是得到错误的最接近答案:

“OrderStatus”对象不支持索引


您正在努力解决的问题与Python中对象的_str___实现有关,请参阅

对象可以实现自定义的_str__方法,因此可以打印对象的字符串表示形式。但是,它可能会令人困惑,因为它不一定对应于对象的结构及其属性


如果不知道使用什么库,我建议您在debugger下检查可用的方法和对象变量,然后使用它们访问所需的属性。

Ok。我将尝试在不使用循环的情况下简化它,然后再次询问。我以为这会是一个简单的解决办法,但我想不会。我刚刚意识到我有一个小的打字错误。许可证本该被许可的。因此,如果mod请求,可以删除此主题。您有权删除自己的帖子。欢迎你这么做!