小编Chu*_*uox的帖子

Python 3 处理错误 TypeError:不允许捕获不从 BaseException 继承的类

当我运行此代码时:

i=0
while i<5:
    i=i+1;
    try:
        SellSta=client.get_order(symbol=Symb,orderId=SellOrderNum,recvWindow=Delay)
    except client.get_order as e:
        print ("This is an error message!{}".format(i))
#End while
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

TypeError: catching classes that do not inherit from BaseException is not allowed
Run Code Online (Sandbox Code Playgroud)

我读了这个有时会显示的胎面Exception TypeError 警告,有时在使用生成器的 throw 方法时不会,而这个无法捕获模拟异常,因为它不继承 BaseException也读了这个https://medium.com/python-pandemonium/a -非常挑剔的except-in-python-d9b994bdf7f0

我用这个代码修复它:

i=0
while i<5:
    i=i+1;
    try:
        SellSta=client.get_order(symbol=Symb,orderId=SellOrderNum,recvWindow=Delay)
    except:
        print ("This is an error message!{}".format(i))
#End while
Run Code Online (Sandbox Code Playgroud)

结果是忽略错误并转到下一个,但我想捕获错误并打印它。

python exception typeerror binance

11
推荐指数
1
解决办法
5万
查看次数

从 Windows 上的命令提示符打开位于 google 文件流驱动器中的文件

我目前正在从 Spyder IDE 运行位于 Google Drive 文件流上的脚本,没有问题,但正在寻找从 anaconda promt 运行的脚本。当我尝试:

cd  G:\My Drive\LBTC API\V0.2
Run Code Online (Sandbox Code Playgroud)

它根本没有做任何事情,如果我尝试,我得到了相同的结果:

cd  G:\
Run Code Online (Sandbox Code Playgroud)

谢谢

windows cmd python-3.x google-drive-api

2
推荐指数
1
解决办法
1304
查看次数