แต่ในภาษา Python ไม่มี switch
ไวยากรณ์
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
switch(ตัวแปร){ // สลับระหว่างกรณี | |
case ค่าที่ต้องการในเงื่อนไขที่1: คำสั่ง;break; // กรณีที่ 1 | |
... | |
case ค่าที่ต้องการในเงื่อนไขที่n: คำสั่ง;break; | |
default: ไม่เข้าเงื่อนไข; | |
} |
0 ความคิดเห็น:
แสดงความคิดเห็น