如何更改Python模块名称? [英] How to change a Python module name?

查看:325
本文介绍了如何更改Python模块名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

仅在重命名文件的情况下可以吗?还是文件中有一个__module__变量来定义其名称?

Is it only possible if I rename the file? Or is there a __module__ variable to the file to define what's its name?

推荐答案

是的,您应该重命名该文件.最好是在完成此操作后,从系统中删除oldname.pycoldname.pyo编译文件(如果存在),否则该模块也可以以旧名称导入.

Yes, you should rename the file. Best would be after you have done that to remove the oldname.pyc and oldname.pyo compiled files (if present) from your system, otherwise the module will be importable under the old name too.

这篇关于如何更改Python模块名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆