品易云推流 关闭
文章详情页
文章 > Python常见问题 > 怎么查看python模块在什么位置

怎么查看python模块在什么位置

Python

头像

yang

2020-04-28 11:03:334372浏览 · 0收藏 · 0评论

查看python模块在什么位置的方法:

若要获取模块的文件名为filename.py,在cmd中输入下面的代码即可获取指定模块的路径:

import os
os.path.abspath('.\\filename.py')   #获得你要导入的模块的路径
'C:\\Users\\14469\\Desktop\\untitled\\filename.py'

复制刚才的路径,然后加到sys.path即可导入模块:

import sys
sys.path.append('C:\\Users\\14469\\Desktop\\untitled\\filename.py'  )

更多Python知识请关注Python视频教程栏目。

关注

关注公众号,随时随地在线学习

本教程部分素材来源于网络,版权问题联系站长!

底部广告图