def volumeofcube():
a = int(input('Enter the length of the side:'))
volume = a**3
#Rounded to one decimal place
volume = str(round(volume, 1))
#The volume is added to its corresponding list
volumeofcubelist.append(volume)
print('The volume of the cube with the side', a,'is', volume)
return volume
这是一个我想导入到另一个文件(main.py)中的函数,它的工作方式如下:
elif shape == 'cube':
volumeofcube()
但是,当我尝试导入时:
import volumes
or
from volumes import volumeofcube()
这些都无法找到volumes.py模块并将其导入
如果您尝试作为导入
对
volumeofcube
方法的调用应该是如果您尝试导入为
你需要去掉括号,正确的语法是:
相关问题 更多 >
编程相关推荐