栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python库文件夹中的

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python库文件夹中的

以treelib为例

C:PROGRAMDATAANACONDA3ENVSPYTHON39LIBSITE-PACKAGESTREELIB
│  exceptions.py
│  misc.py
│  node.py
│  plugins.py
│  tree.py
│  __init__.py

要是没有init文件,有四种方式调用tree.py,都是最原始的方法

import treelib.tree
import treelib.tree as tree
from arithmetic.tree import Tree
from arithmetic import tree

如果有了init.py文件,可以在里边做一个中间步骤

#init.py
from .tree import Tree#.tree即当前文件夹下的tree.py
#from .node import Node

当你此时import treelib时,就已经做完了from treelib.tree import Tree.所以在其他文件中,你就可以这样用

#xxx.py
import treelib
tree = Tree()
参考文献:

https://zhuanlan.zhihu.com/p/115350758

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/326504.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号