擅长:python、mysql、java
<p>在Python中,return语句不会将任何内容打印到屏幕上。实际情况是,您正在以<a href="https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop" rel="nofollow">REPL</a>(交互模式)运行Python,因此函数返回的值将自动显示在屏幕上。在</p>
<p>但是,如果从命令行运行Python(例如,通过执行脚本),函数返回的值将不会显示在屏幕上。。。除非你明确地打印出来。java也是如此:</p>
<pre><code>System.out.println(x); // this is how you print in Java
print(x) // this is how you print in Python
</code></pre>
<p>虽然所有具有<code>return</code>关键字(或等效关键字)的编程语言都不会在屏幕上打印任何内容,<code>return</code>只对从函数或方法返回值有用。显示结果需要单独的指令。在</p>