为什么即使我不输入print,python也会打印? [英] Why does python print even if I don't type print?
问题描述
print "a"; "b"
将输出:
"a"
'b'
只需在控制台中输入int或字符串,即可打印出来.
Simply typing an int or string into the console will cause it to print.
1
将输出:
1
有什么理由或好处吗?
推荐答案
The interactive Python interpreter is a REPL:
一种简单的交互式计算机编程环境,它接受单个用户输入(即单个表达式),对其进行求值,然后将结果返回给用户
a simple, interactive computer programming environment that takes single user inputs (i.e. single expressions), evaluates them, and returns the result to the user
您看到的是每个语句的返回值.考虑一个不太简单的示例,其中返回值与输入不同:
What you are seeing is the return value for each statement. Consider a slightly less simple example where the return value is different from the input:
>>> 2 + 3
5
在探索新的语言或问题领域时,REPL提供的紧密反馈回路特别有用.
The tight feedback loop provided by a REPL can be especially helpful when exploring a new language or problem domain.
这篇关于为什么即使我不输入print,python也会打印?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!