我正在尝试使用 vs-code 访问目录中的文件 Maxoflist.py
。我希望打印列表中的最大值,但事实并非如此。没有发生错误,并且在另一个文件 shipping.py
中定义的函数工作正常。
import shipping
import Maxoflist #imported the entire module shippinng
shipping.calc_shipping() #working good
findmaxoflist() #not working
Maxoflist.py
:
def findmaxoflist():
Items = [5,61,7,2,4,9,1]
Max = Items[0]
for num in Items:
if Max < num:
Max = num
print(f"Maximum Number is: {Max}")
findmaxoflist()
shipping.py
:
def calc_shipping(): #working good when imported
print("Callin the calculate shipping")
最佳答案
确保该目录中的文件没有丢失/删除或者名称拼写正确!
试试这个:
from Maxoflist import findmaxoflist
关于python - 使用一个文件运行良好但另一个文件未导入的位置访问我的目录中的文件(?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55450871/