1. <i id='I2qNJ'><tr id='I2qNJ'><dt id='I2qNJ'><q id='I2qNJ'><span id='I2qNJ'><b id='I2qNJ'><form id='I2qNJ'><ins id='I2qNJ'></ins><ul id='I2qNJ'></ul><sub id='I2qNJ'></sub></form><legend id='I2qNJ'></legend><bdo id='I2qNJ'><pre id='I2qNJ'><center id='I2qNJ'></center></pre></bdo></b><th id='I2qNJ'></th></span></q></dt></tr></i><div id='I2qNJ'><tfoot id='I2qNJ'></tfoot><dl id='I2qNJ'><fieldset id='I2qNJ'></fieldset></dl></div>
      <tfoot id='I2qNJ'></tfoot>
      • <bdo id='I2qNJ'></bdo><ul id='I2qNJ'></ul>
      <legend id='I2qNJ'><style id='I2qNJ'><dir id='I2qNJ'><q id='I2qNJ'></q></dir></style></legend>

      <small id='I2qNJ'></small><noframes id='I2qNJ'>

        为什么我的函数输出打印出“无"?

        时间:2024-04-22

            • <bdo id='mMwze'></bdo><ul id='mMwze'></ul>
                  <tbody id='mMwze'></tbody>

              1. <legend id='mMwze'><style id='mMwze'><dir id='mMwze'><q id='mMwze'></q></dir></style></legend>

              2. <i id='mMwze'><tr id='mMwze'><dt id='mMwze'><q id='mMwze'><span id='mMwze'><b id='mMwze'><form id='mMwze'><ins id='mMwze'></ins><ul id='mMwze'></ul><sub id='mMwze'></sub></form><legend id='mMwze'></legend><bdo id='mMwze'><pre id='mMwze'><center id='mMwze'></center></pre></bdo></b><th id='mMwze'></th></span></q></dt></tr></i><div id='mMwze'><tfoot id='mMwze'></tfoot><dl id='mMwze'><fieldset id='mMwze'></fieldset></dl></div>
              3. <small id='mMwze'></small><noframes id='mMwze'>

                  <tfoot id='mMwze'></tfoot>

                  本文介绍了为什么我的函数输出打印出“无"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  I just learned (am learning) how function parameters work in Python, and I started experimenting with it for no apparent reason, when this:

                  def jiskya(x, y):
                      if x > y:
                          print(y) 
                      else:
                          print(x) 
                  
                  print(jiskya(2, 3))
                  

                  gave the ouput:

                  >>>
                  2
                  None
                  

                  Where did the None come from? And what is it?

                  解决方案

                  It's the return value of the function, which you print out. If there is no return statement (or just a return without an argument), an implicit return None is added to the end of a function.

                  You probably want to return the values in the function instead of printing them:

                  def jiskya(x, y):
                      if x > y:
                          return y
                      else:
                          return x
                  
                  print(jiskya(2, 3))
                  

                  这篇关于为什么我的函数输出打印出“无"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:内置 open 函数中模式 a、a+、w、w+ 和 r+ 的区别? 下一篇:如何将传说从情节中剔除

                  相关文章

                • <small id='J6O5F'></small><noframes id='J6O5F'>

                    <bdo id='J6O5F'></bdo><ul id='J6O5F'></ul>

                    <legend id='J6O5F'><style id='J6O5F'><dir id='J6O5F'><q id='J6O5F'></q></dir></style></legend>
                    <i id='J6O5F'><tr id='J6O5F'><dt id='J6O5F'><q id='J6O5F'><span id='J6O5F'><b id='J6O5F'><form id='J6O5F'><ins id='J6O5F'></ins><ul id='J6O5F'></ul><sub id='J6O5F'></sub></form><legend id='J6O5F'></legend><bdo id='J6O5F'><pre id='J6O5F'><center id='J6O5F'></center></pre></bdo></b><th id='J6O5F'></th></span></q></dt></tr></i><div id='J6O5F'><tfoot id='J6O5F'></tfoot><dl id='J6O5F'><fieldset id='J6O5F'></fieldset></dl></div>

                    <tfoot id='J6O5F'></tfoot>