如何创建自己的python包

 

  • __init__.py文件:
from hqhml import *
  • math1.py文件:
#-*- coding:utf8 -*-

def concat(x,y):
    return x+y

 

  • setup.py文件:
#-*- coding:utf8 -*-

from distutils.core import setup

setup(
name='hqhml',
version='1.0'
packages=['hqhml']
)
  •  导入包:
from hqhml import math1

print(math1.concat(1,2))
  • pycharm如何设置
  1. preference
  2. project structure
  3. add content root : 将自己制作的包的所在目录加载进去就好了

相关文章:

  • 2021-06-30
  • 2021-05-16
  • 2023-03-17
  • 2022-12-23
  • 2021-11-04
  • 2021-04-15
  • 2022-01-14
猜你喜欢
  • 2021-10-25
  • 2021-07-24
  • 2021-07-04
  • 2021-11-28
  • 2022-12-23
  • 2021-09-22
相关资源
相似解决方案