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'>

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

        Why is the output of my function printing out quot;Nonequot;?(为什么我的函数输出打印出“无?)

            • <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))
                  

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

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Split a Pandas column of lists into multiple columns(将 Pandas 的列表列拆分为多列)
                  How does the @property decorator work in Python?(@property 装饰器在 Python 中是如何工作的?)
                  What is the difference between old style and new style classes in Python?(Python中的旧样式类和新样式类有什么区别?)
                  How to break out of multiple loops?(如何打破多个循环?)
                  How to put the legend out of the plot(如何将传说从情节中剔除)
                  Difference between modes a, a+, w, w+, and r+ in built-in open function?(内置 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>

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