zoukankan      html  css  js  c++  java
  • 模块

    Python学习(六)模块 —— 包

    #!/usr/bin/env python3
    # -*- coding: utf-8 -*-
    
    ' a test module '
    
    __author__ = 'xxx'
    
    import sys
    import a.test
    
    a.test.say('aaa')
    
    def test():
        args = sys.argv
        if len(args)==1:
            print('Hello, world!')
        elif len(args)==2:
            print('Hello, %s!' % args[1])
        else:
            print('Too many arguments!')
    
    if __name__=='__main__':
        test()
    
    #当我们在命令行运行hello模块文件时,Python解释器把一个特殊变量__name__置为__main__,而如果在其他地方导入该hello模块时,
    #if判断将失败,因此,这种if测试可以让一个模块通过命令行运行时执行一些额外的代码,最常见的就是运行测试。
    
    #类似__xxx__这样的变量是特殊变量,可以被直接引用,但是有特殊用途,比如上面的__author__,__name__就是特殊变量,
    #hello模块定义的文档注释也可以用特殊变量__doc__访问,我们自己的变量一般不要用这种变量名
    
    #类似_xxx和__xxx这样的函数或变量就是非公开的(private),不应该被直接引用,比如_abc,__abc等
    #Python并没有一种方法可以完全限制访问private函数或变量,但是,从编程习惯上不应该引用private函数或变量
    from a import test
    
    test.say('aa')

    安装第三方模块

    pip install Pillow

     

    源代码安装

    python install setup.py
  • 相关阅读:
    无题
    1.1tensorflow2.0 张量
    某某大肠_tidb_集群创建用户
    某某大肠_替换TiDB 3.0集群的tidb-server命令工具
    某某大肠_配置spark的thriftserver模块
    date_and_time
    SpringBoot整合Mybatis
    SpringBoot(3)Thymeleaf使用详解
    SpringBoot(2)实现CRUD
    SpringBoot(1)入门篇
  • 原文地址:https://www.cnblogs.com/jzm17173/p/4997690.html
Copyright © 2011-2022 走看看