Python int()ฟังก์ชัน
ตัวอย่าง
แปลงตัวเลข 3.5 เป็นจำนวนเต็ม:
x =
int(3.5)
ความหมายและการใช้งาน
ฟังก์ชันint()
แปลงค่าที่ระบุเป็นจำนวนเต็ม
ไวยากรณ์
int(value, base)
ค่าพารามิเตอร์
Parameter | Description |
---|---|
value | A number or a string that can be converted into an integer number |
base | A number representing the number format. Default value: 10 |
ตัวอย่างเพิ่มเติม
ตัวอย่าง
แปลงสตริงเป็นจำนวนเต็ม:
x =
int("12")