zoukankan      html  css  js  c++  java
  • Day 15 包与常用模块

    day15思维导图

    一 包 package

    Packages are a way of structuring Python’s module namespace by using “dotted module names”

    A package is a collection of Python modules, i.e., a package is a directory of Python modules containing an additional __init__.py file. The __init__.py distinguishes/dɪˈstɪŋɡwɪʃ/(分辨) a package from a directory that just happens to contain a bunch of Python scripts. Packages can be nested to any depth, provided that the corresponding directories contain their own __init__.py file.

    A package, in essence, is like a directory holding subpackages and modules. While we can create our own packages, we can also use one from the Python Package Index (PyPI) to use for our projects.

    __init__.py

    The package folder contains a special file called init.py, which stores the package's content. It serves two purposes:

    The Python interpreter recognizes a folder as the package if it contains init.py file. init.py exposes specified resources from its modules to be imported.

    An empty init.py file makes all functions from above modules available when this package is imported. Note that init.py is essential for the folder to be recognized by Python as a package. You can optionally define functions from individual modules to be made available.

    二 Logging module

    Standard Library Logging Module

    Python comes with a logging module in the standard library that provides a flexible framework for emitting(发出) log messages from Python programs. This module is widely used by libraries and is the first go-to point for most developers when it comes to logging.

    The module provides a way for applications to configure different log handlers and a way of routing log messages to these handlers. This allows for a highly flexible configuration that can deal with a lot of different use cases.

    Logging Levels

    When you set a logging level in Python using the standard module, you’re telling the library you want to handle all events from that level on up. If you set the log level to INFO, it will include INFO, WARNING, ERROR, and CRITICAL messages. NOTSET and DEBUG messages will not be included here.

    Conclusion

    It is not necessary to know all of these, because it can be copied and used directly

  • 相关阅读:
    ios实现程序切入后台,实现后台任务 (转自)
    iOS 设置页面的代码编写
    IOS 关于扬声器和听话筒的设置 ----自己试验过的,可以达到扩音器和听筒播放的效果
    转载自@机智的新手:使用Auto Layout中的VFL(Visual format language)--代码实现自动布局
    web前端基础知识-(六)web框架
    web前端基础知识-(五)jQuery
    web前端基础知识-(四)DOM
    web前端基础知识-(三)JavaScript基本操作
    web前端基础知识-(二)CSS基本操作
    web前端基础知识-(一)html基本操作
  • 原文地址:https://www.cnblogs.com/fengshili666/p/14237410.html
Copyright © 2011-2022 走看看