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

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

Python 3: print() เป็น built-in function พิมพ์ argument ไปหน้าจอ:

>>> print("Hello!")
Hello!
>>> print(5)
5

Python 2: print เป็น statement:

>>> print "Hello!"
Hello!
>>> print 5
5

แปลง object เป็น string แล้วพิมพ์ เหตุผลเปลี่ยนเป็น function