<p>我在写一个代码,里面有各种各样的函数。我为每个特定函数创建了.py文件,并在需要时导入它们。示例代码:</p>
<pre><code># main.py file
import addition
import subtraction
a = input("enter a")
b = input("enter b")
c = input("enter 1 to add 2 to subtract")
if a == 1:
addition.add(a, b) # call to add function in addition module
subtraction.minus(a, b) # call to subtract function in subtraction module
# More code here
# addition.py module
import game # import another self-created module
y = input("do you want to play a game? Enter 1 if yes and 0 if no")
if y == 1:
game.start()
# more similar code
</code></pre>
<p>我现在可以看到在多个级别调用模块。所以我的问题是在我的<code>game</code>模块中,如果我使用exit命令来结束代码,它会结束整个执行还是仅仅是<code>game</code>模块?
当我在代码中遇到异常时,我需要一个命令来退出整个代码的执行。在</p>
<p><strong>注意</strong>:我不希望exit命令在控制台上打印任何内容。就像我以前那样系统出口()以前在另一个项目中,它在控制台上打印警告,我不需要它,因为这个项目是为那些不了解警告是什么的人准备的。在</p>