Devdit
 

คำสั่งในการรับข้อมูลในภาษา Python คือข้อใด

2.3K

คำสั่งในการรับข้อมูลในภาษา Python คือข้อใด คำตอบ คือ คำสั่ง input (รองรับ Python v 3.x) ถ้าเป็น Python v 2.x คือ raw_input สามารถเขียนโปรแกรมได้ดังนี้

 

ตัวอย่าง คำสั่งในการรับข้อมูลในภาษา Python

name = input('Please input name : ')
age = int(input('Please input age : '))

print('Hello, '+name+' '+str(age)+' year old')

ผลลัพธ์

Please input name : Robot
Please input age : 20
Hello, Robot 20 year old
เขียน 2 ปีที่แล้ว
ชอบ
ลิ้งก์
แชร์
Devdit มีช่อง YouTube แล้ว
เราสร้างวิดีโอเกี่ยวกับเทคโนโลยี ทำตามง่ายๆ