py/log
This commit is contained in:
parent
e76656855d
commit
1fb36aac9e
1 changed files with 14 additions and 3 deletions
|
@ -4,7 +4,7 @@ Snippets
|
|||
Hello world
|
||||
-----------
|
||||
|
||||
.. code:: python3
|
||||
.. code-block:: python3
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("Hello, world!")
|
||||
|
@ -23,17 +23,28 @@ Links
|
|||
Remove
|
||||
^^^^^^
|
||||
|
||||
.. code:: python3
|
||||
.. code-block:: python3
|
||||
|
||||
import shutil
|
||||
shutil.rmtree(path)
|
||||
|
||||
Log
|
||||
---
|
||||
|
||||
.. code-block:: python3
|
||||
|
||||
file_handler = logging.FileHandler('log.txt')
|
||||
file_handler.setFormatter(formatter)
|
||||
file_handler.setLevel(logging.INFO)
|
||||
|
||||
logger.addHandler(file_handler)
|
||||
|
||||
Web
|
||||
---
|
||||
|
||||
Get
|
||||
^^^
|
||||
|
||||
.. code:: python3
|
||||
.. code-block:: python3
|
||||
|
||||
requests.get(url).content.decode(charset)
|
||||
|
|
Loading…
Reference in a new issue