Why is print not a function in python?

前端 未结 6 2000
情深已故
情深已故 2021-02-13 13:21

Why is print a keyword in python and not a function?

6条回答
  •  北恋
    北恋 (楼主)
    2021-02-13 13:34

    The print statement in Python 2.x has some special syntax which would not be available for an ordinary function. For example you can use a trailing , to suppress the output of a final newline or you can use >> to redirect the output to a file. But all this wasn't convincing enough even to Guido van Rossum himself to keep it a statement -- he turned print into a function in Python 3.x.

提交回复
热议问题