zoukankan      html  css  js  c++  java
  • python_如何建立包

    步骤:

      (1)包的名称为drawing

      (2)drawing中建立模块color和shape

    视图:

    备注:

      (1) E:/python_script/已经加入到系统变量path中

      (2) 建立包时,包下面必须包含__init__.py的文件(此文件中可以没有任何内容)

    调用包下的模块:

      (1)color.py 代码

    def red():
        print "the color is red"

      (2)shape.py 代码

        

    def circle():
        print "the shape is circle"

      (3)调用color和shape中函数的代码

    #coding:utf-8
    
    #import drawing
    import drawing.color
    from drawing import shape
    
    #引用的时候,需要加入包名和模块名
    drawing.color.red()
    #引用的时候,直接用模块名即可
    shape.circle()

          运行结果:

          

  • 相关阅读:
    8.3学习日志
    8.2学习日志
    8.1学习日志
    Chapter 2
    未命名 1
    pugixml
    C++使用Json作为数据包装格式的通信
    项目FAQ
    xcode语法高亮插件
    【转】jsoncpp在xcode中的使用
  • 原文地址:https://www.cnblogs.com/zhuhaiying/p/5196068.html
Copyright © 2011-2022 走看看