วันจันทร์ที่ 24 สิงหาคม พ.ศ. 2558

List in Python

List ในภาษา Python เปรียบได้กับ ArrayList ในภาษา Java เป็น Data Structure ที่ใช้เก็บตัวแปรหลายๆตัว โดยสามารถเพิ่มขนาดได้ตามต้องการ มีโครงสร้างการประกาศดังนี้

      list1 = ['physics', 'chemistry', 1997, 2000]
      list2 = [1, 2, 3, 4, 5 ]
      list3 = ["a", "b", "c", "d"]

ถ้าต้องการจะสร้าง List เปล่า (ไม่มีข้อมูลอยู่ข้างใน) ทำได้โดย

      list = []

สามารถไปดู Functions & Methods ของ List ได้ที่

https://docs.google.com/spreadsheets/d/1Dtu9S-cUN_UuVOZ_rklgkZ62C0CHNsOFNat3pZyT3e8/edit?usp=sharing




ไม่มีความคิดเห็น:

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