โดย dawthana » 28/12/2016 5:24 pm
ตัวแปรชนิด Dictionary (ดิกชันนารี)
ตัวแปรชนิด
Dictionary ของ #Python จะคล้ายกับตัวแปร
Array (อาร์เรย์) ในภาษา
PHP (พีเอชพี) โดยจะต้องมี Key (คีย์) และ Value(แวลู่) คู่กันเสมอ
การกำหนดตัวแปร Dictionary
-การกำหนดค่าให้กับตัวแปร Dictionary จะต้องอยู่ภายใต้เครื่องหมาย {...}
ตัวอย่างการแสดงผล ซึ่งการแสดงผลจะเรียงลำดับ index จากค่าน้อยไปหามาก
- dic1.png (37.39 KiB) Viewed 1774 times
การเพิ่มค่าให้กับตัวแปร Dictionary
ตัวอย่างการแสดงผลการเพิ่มค่าตัวแปร
- dic3.png (32.94 KiB) Viewed 1774 times
การลบค่าในตัวแปร dictionary
ตัวอย่างการแสดงผลการลบค่าตัวแปร
- dic4.png (31.72 KiB) Viewed 1774 times
ความแตกต่างระหว่าง List , Tuple และ Dictionary
List (ลิส)
Key Auto(คีย์ออโต้) , Update(อัพเดท)ได้ และ Delete(ดีลลีท)ได้
Tuple (ทูเปิล)
Key Auto , Updateไม่ได้ และ Deleteไม่ได้
Dictionary
กำหนด Key เอง , Updateได้ และ Deleteได้
ศึกษาข้อมูลจาก
https://www.youtube.com/watch?v=hSQ4gce ... MM&index=8
[b]ตัวแปรชนิด Dictionary (ดิกชันนารี)[/b]
ตัวแปรชนิด [url=https://www.mindphp.com/%E0%B8%9A%E0%B8%97%E0%B9%80%E0%B8%A3%E0%B8%B5%E0%B8%A2%E0%B8%99%E0%B8%AD%E0%B8%AD%E0%B8%99%E0%B9%84%E0%B8%A5%E0%B8%99%E0%B9%8C/83-python/3400-%E0%B8%95%E0%B8%B1%E0%B8%A7%E0%B9%81%E0%B8%9B%E0%B8%A3%E0%B8%8A%E0%B8%99%E0%B8%B4%E0%B8%94-dictionary.html]Dictionary[/url] ของ #Python จะคล้ายกับตัวแปร [url=https://www.mindphp.com/%E0%B8%9A%E0%B8%97%E0%B9%80%E0%B8%A3%E0%B8%B5%E0%B8%A2%E0%B8%99%E0%B8%AD%E0%B8%AD%E0%B8%99%E0%B9%84%E0%B8%A5%E0%B8%99%E0%B9%8C/%E0%B8%9A%E0%B8%97%E0%B9%80%E0%B8%A3%E0%B8%B5%E0%B8%A2%E0%B8%99-php/64-use-array.html]Array (อาร์เรย์)[/url] ในภาษา [url=https://www.mindphp.com/%E0%B8%9A%E0%B8%97%E0%B9%80%E0%B8%A3%E0%B8%B5%E0%B8%A2%E0%B8%99%E0%B8%AD%E0%B8%AD%E0%B8%99%E0%B9%84%E0%B8%A5%E0%B8%99%E0%B9%8C/%E0%B8%9A%E0%B8%97%E0%B9%80%E0%B8%A3%E0%B8%B5%E0%B8%A2%E0%B8%99-php.html]PHP (พีเอชพี)[/url] โดยจะต้องมี Key (คีย์) และ Value(แวลู่) คู่กันเสมอ
[b]การกำหนดตัวแปร Dictionary[/b]
-การกำหนดค่าให้กับตัวแปร Dictionary จะต้องอยู่ภายใต้เครื่องหมาย {...}
ตัวอย่างการแสดงผล ซึ่งการแสดงผลจะเรียงลำดับ index จากค่าน้อยไปหามาก
[attachment=2]dic1.png[/attachment]
[b]การเพิ่มค่าให้กับตัวแปร Dictionary[/b]
ตัวอย่างการแสดงผลการเพิ่มค่าตัวแปร
[attachment=1]dic3.png[/attachment]
[b]การลบค่าในตัวแปร dictionary[/b]
ตัวอย่างการแสดงผลการลบค่าตัวแปร
[attachment=0]dic4.png[/attachment]
[b]ความแตกต่างระหว่าง List , Tuple และ Dictionary[/b]
[b]List (ลิส)[/b]
Key Auto(คีย์ออโต้) , Update(อัพเดท)ได้ และ Delete(ดีลลีท)ได้
[b]Tuple (ทูเปิล)[/b]
Key Auto , Updateไม่ได้ และ Deleteไม่ได้
[b]Dictionary[/b]
กำหนด Key เอง , Updateได้ และ Deleteได้
ศึกษาข้อมูลจาก [url]https://www.youtube.com/watch?v=hSQ4gceSMsU&list=PLLi1ciqQAf8TVFbJpl7XY23lzdKrpxsMM&index=8[/url]