开发者

Python try and catch is not working in jupyter note book

HI I am new to jupyter notebook. I am not sure why this block of 开发者_开发问答code executes both try and except in my code

print('time :' , datetime.now())
try:  
    print("Command executed")
    pd.read_sql('''select * from table  ''')
    print("Command executed")
except:
    print("Command skipped")

Here is the output I am getting

time : 2022-12-07 06:40:37.294965
Command executed
Command skipped


You check points should be different..You alredy used Command executed ...user different check point after query to see diffrence.

print('time :' , datetime.now())
try:  
    print("Execution started")
    pd.read_sql('''select * from table  ''')
    print("Command executed")
except:
    print("Command skipped")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜