热线电话:13121318867

登录
2019-04-18 阅读量: 450
python如何使用try函数?

python如何使用try函数?

# Python code to illustrate

# working of try()

def divide(x, y):

try:

# Floor Division : Gives only Fractional Part as Answer

result = x // y

print("Yeah ! Your answer is :", result)

except ZeroDivisionError:

print("Sorry ! You are dividing by zero ")

# Look at parameters and note the working of Program

divide(3, 2)

输出 :

('Yeah ! Your answer is :', 1)
54.5455
2
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子