python - 导入本地 .py 文件时如何确保导入包
问题描述
导入本地python文件时,如何确保也导入了必要的包?
例子:
我想从位于同一目录中的 pythonfile 导入 myfunction
from pythonfile import myfunction
但是 myfunction 使用库。如何确保正确导入库?
## this is pythonfile
import library
def myfunction():
library.dosomething()
我想我可以将导入放在函数中,但我不想每次都导入包。
解决方案
推荐阅读
- javascript - 将 js 文件链接到 html 以获得 Dreamweaver 中的浮动按钮
- javascript - 一个 js 函数的奇怪行为,用于在移动设备中删除和添加一个类,而 sruncutre 基本相同
- powershell - 使用 Powershell 在重命名脚本中自动填充部分计算机名称?
- javascript - 通过 MailApp.sendEmail() 发送时,HTML 正文未显示在电子邮件中
- javascript - 通过按下按钮显示的网络摄像头图像
- javascript - 如何检查嵌入图像是否具有有效/工作链接?
- r - 无法使用 R 中的函数创建新列
- business-objects - 业务对象 WEBI 报告拆分为多个页面(不是选项卡)
- php - getstream.io REST api 的完整参考文献在哪里?
- encryption - RAML 中的加密数据类型