<tfoot id='CBNgQ'></tfoot>

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

      1. <legend id='CBNgQ'><style id='CBNgQ'><dir id='CBNgQ'><q id='CBNgQ'></q></dir></style></legend>
          <bdo id='CBNgQ'></bdo><ul id='CBNgQ'></ul>

        <i id='CBNgQ'><tr id='CBNgQ'><dt id='CBNgQ'><q id='CBNgQ'><span id='CBNgQ'><b id='CBNgQ'><form id='CBNgQ'><ins id='CBNgQ'></ins><ul id='CBNgQ'></ul><sub id='CBNgQ'></sub></form><legend id='CBNgQ'></legend><bdo id='CBNgQ'><pre id='CBNgQ'><center id='CBNgQ'></center></pre></bdo></b><th id='CBNgQ'></th></span></q></dt></tr></i><div id='CBNgQ'><tfoot id='CBNgQ'></tfoot><dl id='CBNgQ'><fieldset id='CBNgQ'></fieldset></dl></div>
      2. NameError:Python 3 中未定义全局名称“xrange"

        NameError: global name #39;xrange#39; is not defined in Python 3(NameError:Python 3 中未定义全局名称“xrange)
          <bdo id='6HsGA'></bdo><ul id='6HsGA'></ul>

          1. <legend id='6HsGA'><style id='6HsGA'><dir id='6HsGA'><q id='6HsGA'></q></dir></style></legend>
          2. <tfoot id='6HsGA'></tfoot>

                  <small id='6HsGA'></small><noframes id='6HsGA'>

                    <tbody id='6HsGA'></tbody>

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

                  本文介绍了NameError:Python 3 中未定义全局名称“xrange"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  I am getting an error when running a python program:

                  Traceback (most recent call last):
                    File "C:Program Files (x86)Wing IDE 101 4.1srcdebug	server\_sandbox.py", line 110, in <module>
                    File "C:Program Files (x86)Wing IDE 101 4.1srcdebug	server\_sandbox.py", line 27, in __init__
                    File "C:Program Files (x86)Wing IDE 101 4.1srcdebug	serverclassinventory.py", line 17, in __init__
                  builtins.NameError: global name 'xrange' is not defined
                  

                  The game is from here.

                  What causes this error?

                  解决方案

                  You are trying to run a Python 2 codebase with Python 3. xrange() was renamed to range() in Python 3.

                  Run the game with Python 2 instead. Don't try to port it unless you know what you are doing, most likely there will be more problems beyond xrange() vs. range().

                  For the record, what you are seeing is not a syntax error but a runtime exception instead.


                  If you do know what your are doing and are actively making a Python 2 codebase compatible with Python 3, you can bridge the code by adding the global name to your module as an alias for range. (Take into account that you may have to update any existing range() use in the Python 2 codebase with list(range(...)) to ensure you still get a list object in Python 3):

                  try:
                      # Python 2
                      xrange
                  except NameError:
                      # Python 3, xrange is now named range
                      xrange = range
                  
                  # Python 2 code that uses xrange(...) unchanged, and any
                  # range(...) replaced with list(range(...))
                  

                  or replace all uses of xrange(...) with range(...) in the codebase and then use a different shim to make the Python 3 syntax compatible with Python 2:

                  try:
                      # Python 2 forward compatibility
                      range = xrange
                  except NameError:
                      pass
                  
                  # Python 2 code transformed from range(...) -> list(range(...)) and
                  # xrange(...) -> range(...).
                  

                  The latter is preferable for codebases that want to aim to be Python 3 compatible only in the long run, it is easier to then just use Python 3 syntax whenever possible.

                  这篇关于NameError:Python 3 中未定义全局名称“xrange"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                  Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)
                    <legend id='QRw1B'><style id='QRw1B'><dir id='QRw1B'><q id='QRw1B'></q></dir></style></legend><tfoot id='QRw1B'></tfoot>

                        • <bdo id='QRw1B'></bdo><ul id='QRw1B'></ul>

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

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

                              <tbody id='QRw1B'></tbody>