Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> Python

Hàm input() trong Python làm gì?


Hàm input() hiển thị prompt (optional arg), nhận input user. Python 2.x: trả về data user nhập theo format Python interpret (ví dụ "Hello" -> string, 5 -> int). Python 3.x: trả về string format.

Ví dụ

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