python - 在 jupyter notebook 的 python 源代码中调用函数
问题描述
我的python文件中有这个(称为myLib.py)
def add(x, y):
return x + y
在我的 jupeter 笔记本中,我有以下代码:
import myLib as myLib
y=myLib.add(1,2)
print(y)
当我运行 jupyter 单元时,我收到此错误:
AttributeError Traceback (most recent call last)
<ipython-input-10-9b942a9ce18f> in <module>
1 import myLib as myLib
----> 2 y=myLib.add(1,2)
3 print(y)
AttributeError: module 'myLib' has no attribute 'add'
我正在使用视觉工作室
有什么问题,我该如何解决?
解决方案
推荐阅读
- prometheus - 使用警报管理器将数据发送到外部 API
- node.js - nodejs中的动态路由在表单中使用GET方法
- python - 进入otp页面时如何自动进行社交登录
- r - 猿阅读newick树时出错
- hibernate - Grails 如何在 g:each 中显示 HQL JOIN 值
- python - 错误:“管道的最后一步应该实现 fit 或者是字符串 'passthrough'
- html - 为什么这个文本在它的位置?
- python-3.x - 使用 etree 解析 python xml
- android - 如何使用 kotlin 在片段中使用“getActivity()”
- java - 有没有办法用java代码检测nvidia驱动程序版本(也许使用jogl)?