尝试在当前文件中添加python文件时出现错误

时间:2019-06-29 10:14:10

标签: python pycharm

enter image description here我已经在pycharm中创建了一个文件夹,并在其中创建了一个文件。想要将其导入到我的当前文件中。 enter image description here

1 个答案:

答案 0 :(得分:0)

例外情况是告诉您add没有定义,因为它不是Python的关键字,也不是您要导入的函数(例如from this_module import add)。

如果您想对两个元素求和,则需要内置函数sum(它需要一个可迭代的函数,如列表),因此您的代码将变为

a=2
b=3
c=sum([a,b])
print(c)  # 5

编辑:第二张屏幕截图之后,您需要调用 from airthmetic.airthmetic import add

这是算术

相关问题