python-3.x - from import python code doesn't work correctly
问题描述
I created a module as mathfunctions.py
including four functions, then created another module in which call one function from mathfunctions.py
through from...import code
.
When I run the second module, all four functions were executed.
my first module:
def add (x,y):
return x + y
x = int(input("Please Enter the first number:"))
y = int(input("Please Enter the second number:"))
result = add (x,y)
print ("The result is:" , result)
def subtract (x,y):
return x - y
x = int(input("Please Enter the first number:"))
y = int(input("Please Enter the second number:"))
result = subtract (x,y)
print ("The result is:" , result)
def multiply (x,y):
return x * y
x = int(input("Please Enter the first number:"))
y = int(input("Please Enter the second number:"))
result = multiply (x,y)
print ("The result is:" , resudelt)
def division (x,y):
if y != 0:
return x / y
else:
print ("Please Enter the correct number:")
x = int(input("Please Enter the first number:"))
y = int(input("Please Enter the second number:"))
result = division (x,y)
print ("The result is:" , result)
my second module:
from mathfunctions import add
add (x,y)
解决方案
推荐阅读
- flutter - 地图
在事先不知道数据的情况下访问任何类型的地图 - c++ - 我的程序不会打开文本文件。外流 CPP
- python - 如何从 Contour Next One USB 血糖仪中提取数据?
- reactjs - firebase 会自动加密密码吗?如果我想查看我在 Firebase 应用中输入的密码,该怎么做?
- pdf - 通过原始文本操作将整个 pdf 插入另一个
- google-api - Google API OAuth2 刷新令牌突然被撤销
- mongodb - Mongo:如何在(非常)大集合中删除重复项?
- android - Ionic React(电容器)中的 Google Play 游戏服务
- reactjs - Firestore 在哪里过滤并将数据添加到结果中
- c# - 在 Razor Pages 应用程序中获取 Web api 控制器方法的 URL?