• Python模块


    using_sys.py

    import sys
    print ('the command line argument are:')
    for i in sys.argv:
        print (i)
    print ('
    
     the python path is', sys.path, '
    ')
    

    using_name.py

    if __name__ =='__main__':
        print ('this program is being run by itself')
    else:
        print ('i am being imported from another module')
    

    mymodule.py

    def sayhi():
        print ('Hi, this is my module speaking.')
    version='0.1'
    sayhi()
    

    mymodule_demo.py

    import mymodule
    mymodule.sayhi()
    print ('Version', mymodule.version)
    

    mymodule_demo2.py

    from mymodule import sayhi,version
    sayhi()
    print ('version', version)
    

    dir()函数

    >>> import sys
    >>> dir (sys)
    ['__displayhook__', '__doc__', '__excepthook__', '__interactivehook__', '__loader__', '__name__', '__package__', '__spec__', '__stderr__', '__stdin__', '__stdout__', '_clear_type_cache', '_current_frames', '_debugmallocstats', '_getframe', '_home', '_mercurial', '_xoptions', 'api_version', 'argv', 'base_exec_prefix', 'base_prefix', 'builtin_module_names', 'byteorder', 'call_tracing', 'callstats', 'copyright', 'displayhook', 'dllhandle', 'dont_write_bytecode', 'exc_info', 'excepthook', 'exec_prefix', 'executable', 'exit', 'flags', 'float_info', 'float_repr_style', 'get_coroutine_wrapper', 'getallocatedblocks', 'getcheckinterval', 'getdefaultencoding', 'getfilesystemencoding', 'getprofile', 'getrecursionlimit', 'getrefcount', 'getsizeof', 'getswitchinterval', 'gettrace', 'getwindowsversion', 'hash_info', 'hexversion', 'implementation', 'int_info', 'intern', 'is_finalizing', 'maxsize', 'maxunicode', 'meta_path', 'modules', 'path', 'path_hooks', 'path_importer_cache', 'platform', 'prefix', 'set_coroutine_wrapper', 'setcheckinterval', 'setprofile', 'setrecursionlimit', 'setswitchinterval', 'settrace', 'stderr', 'stdin', 'stdout', 'thread_info', 'version', 'version_info', 'warnoptions', 'winver']
    >>> sys.__name__
    'sys'
    >>> sys.version
    '3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:16:59) [MSC v.1900 32 bit (Intel)]'
    >>> dir(print)
    ['__call__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__self__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__text_signature__']
    >>> print.__doc__
    "print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
    
    Prints the values to a stream, or to sys.stdout by default.
    Optional keyword arguments:
    file:  a file-like object (stream); defaults to the current sys.stdout.
    sep:   string inserted between values, default a space.
    end:   string appended after the last value, default a newline.
    flush: whether to forcibly flush the stream."
    
  • 相关阅读:
    Maven Nexus 上传jar到本地仓库。
    java Web与Flex通过HTTP service 通信 并解析Map 数据。
    JACOB调用WORD书签修改WORD文档,并生成html显示到页面中
    去除java list 中的 [] 括号
    2019-2020-2 20175222 《网络对抗技术》Exp9 Web安全基础
    2019-2020-2 20175222 《网络对抗技术》 Exp 8 Web基础
    2019-2020-2 20175222 《网络对抗技术》 Exp7 网络欺诈防范
    2019-2020-2 20175222 《网络对抗技术》 Exp6 MSF基础应用
    2019-2020-2 20175222《网络对抗技术》 Exp5 信息搜集与漏洞扫描
    2019-2020-2 20175222罗雨石 《网络对抗技术》 Exp4 恶意代码分析
  • 原文地址:https://www.cnblogs.com/oskb/p/5069841.html
Copyright © 2020-2023  润新知