มี 3 วิธีหลักในการเริ่มต้น Python:
1. Interactive Interpreter
เริ่มจาก command line (Unix, DOS, Windows):
$ python # Unix/Linux python% # Unix/Linux C:> python # Windows/DOS
ตัวเลือกบรรทัดคำสั่ง:
| ลำดับ | ตัวเลือกและคำอธิบาย |
|---|---|
| 1 | -d : debug output |
| 2 | -O : optimized bytecode (.pyo) |
| 3 | -S : ไม่รัน import site ตอนเริ่มต้น |
| 4 | -v : verbose (trace import) |
| 5 | -X : disable class-based exceptions (เก่า) |
| 6 | -c cmd : รันสคริปต์จากสตริง |
| 7 | file : รันสคริปต์จากไฟล์ |
2. Script from Command-line
$ python script.py # Unix/Linux python% script.py # Unix/Linux C:> python script.py # Windows/DOS
หมายเหตุ: ต้องตั้งสิทธิ์ไฟล์ให้รันได้ (execution permission)
3. Integrated Development Environment (IDE)
- Unix - IDLE เป็น IDE แรกของ Python
- Windows - PythonWin เป็น GUI IDE แรก
- Macintosh - IDLE พร้อม MacPython
ห้าตั้งค่าสภาพแวดล้อมไม่ได้ ให้ขอความช่วยเหลือจาก system admin ตรวจสอบให้แน่ใจว่า Python ทำงานถูกต้อง