ITPub博客

首页 > IT职业 > IT职场 > 怎么查看python模块在什么位置

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

IT职场 作者:jhmaple 时间:2021-09-11 10:17:51 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视频教程栏目。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1678/viewspace-2833825/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-04-15

  • 博文量
    547
  • 访问量
    6013