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

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

      <legend id='XZd5N'><style id='XZd5N'><dir id='XZd5N'><q id='XZd5N'></q></dir></style></legend>
        <bdo id='XZd5N'></bdo><ul id='XZd5N'></ul>

        Python 文件 - 相互导入

        时间:2023-09-14
      1. <tfoot id='0TvNJ'></tfoot>

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

                  <bdo id='0TvNJ'></bdo><ul id='0TvNJ'></ul>
                  本文介绍了Python 文件 - 相互导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想让我的两个 python 文件相互导入一些方法.这似乎给了我导入错误.

                  I would like for two of my python files to import some methods from each other. This seems to be giving me import errors.

                  示例:

                  file_A.py:

                  from file_B import do_B_stuff
                  

                  file_B.py:

                  from file_A import do_A_stuff
                  

                  我之所以尝试这样做是因为我想以对我来说直观的方式来组织我的项目,而不是按照对编译器有意义的方式来组织它.

                  The reason I am trying to do this is because I would like to organize my project in the way it intuitively makes sense to me as opposed to organizing it with respect to what makes sense to the compiler.

                  有没有办法做到这一点?

                  Is there a way to do this?

                  谢谢!

                  推荐答案

                  不要直接使用其他模块中的名称.

                  Don't use the names within the other module directly.

                  import file_B
                  
                  def something():
                      file_B.do_B_stuff
                  

                  file_B.py

                  import file_A
                  
                  def something():
                      file_A.do_A_stuff
                  

                  这篇关于Python 文件 - 相互导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何获取 Python 编译时使用的选项列表? 下一篇:何时或为什么在 Python 中使用相对导入

                  相关文章

                  最新文章

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

                    <legend id='SgrkU'><style id='SgrkU'><dir id='SgrkU'><q id='SgrkU'></q></dir></style></legend>

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