อินพุต Python () ฟังก์ชั่น
ตัวอย่าง
ขอชื่อผู้ใช้และพิมพ์:
print('Enter your name:')
x = input()
print('Hello, ' + x)
ความหมายและการใช้งาน
ฟัง ก์input()
ชั่นนี้อนุญาตให้ผู้ใช้ป้อนข้อมูล
ไวยากรณ์
input(prompt)
ค่าพารามิเตอร์
Parameter | Description |
---|---|
prompt | A String, representing a default message before the input. |
ตัวอย่างเพิ่มเติม
ตัวอย่าง
ใช้พารามิเตอร์พร้อมต์เพื่อเขียนข้อความก่อนอินพุต:
x = input('Enter your name:')
print('Hello, ' + x)