How to change a Python module name?

后端 未结 7 717
暗喜
暗喜 2021-01-02 23:56

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

7条回答
  •  [愿得一人]
    2021-01-03 00:40

    You can change the name used for a module when importing by using as:

    import foo as bar
    print bar.baz
    

提交回复
热议问题