Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

ฟังก์ชัน raw_input() ใน Python ทำอะไร?

raw_input() แสดง prompt รับ input คืน string เสมอ:

name = raw_input("What is your name? ")
print "Hello, %s." % name

ต่างจาก input() ที่พยายาม interpret ค่า ควรใช้ raw_input() + custom parsing

หมายเหตุ: Python 3 ไม่มี raw_input() ใช้ input() แทน