zoukankan      html  css  js  c++  java
  • 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."
    
  • 相关阅读:
    可变参数宏...和__VA_ARGS__
    gitolite
    CentOS 6.4 搭建git 服务器
    github简单使用教程
    【Github教程】史上最全github使用方法:github入门到精通
    redis安装与参数说明
    如何解决redis高并发客户端频繁time out?
    Redis配置文件参数说明
    Redis系列-存储篇hash主要操作函数小结
    Redis常用命令解析——INFO, MONITOR, SLOWLOG
  • 原文地址:https://www.cnblogs.com/oskb/p/5069841.html
Copyright © 2011-2022 走看看