From 1fb36aac9e2e10441f3847d7fd5ddde2a4eeee26 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 25 Jun 2024 11:28:32 +0200 Subject: [PATCH] py/log --- rtfd/public/python3/snippets.rst | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/rtfd/public/python3/snippets.rst b/rtfd/public/python3/snippets.rst index 9d355f4..c2874ff 100644 --- a/rtfd/public/python3/snippets.rst +++ b/rtfd/public/python3/snippets.rst @@ -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)