ซ่อมคอมพิวเตอร์นอกสถานที่ บางกะปิ
www.becomz.com

วันพฤหัสบดีที่ 10 มกราคม พ.ศ. 2556

python try-except


ประยุกต์กับ Website

Algorithm
เริ่ม
     │
     ▼
Try
     │
     ▼
Error ?
     │
 ┌───┴────┐
 │        │
No       Yes
 │        │
else    except
 │        │
 └───┬────┘
     │
 finally
     │
 outside

Code

try:
    x = int(input("x = "))
    y = int(input("y = "))

    print(x / y)

except ValueError:
    print("Please enter number")

except ZeroDivisionError:
    print("Cannot divide by zero")

else:
    print("Everything OK")

finally:
    print("Program Finished")

print("Outside")

Login

User



Username



Password



try



Database



except



Database Error



finally



Close Connection

Share:

0 ความคิดเห็น:

แสดงความคิดเห็น

Disqus Shortname

Comments system

ขับเคลื่อนโดย Blogger.

จำนวนการดูหน้าเว็บรวม

Blog Archive

Post Top Ad

คลังบทความของบล็อก

Author Details

Menu - Pages

Business

Random Posts

Recent

Popular

Blog Archive