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
|
Hello world
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
.. code:: python3
|
.. code-block:: python3
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print("Hello, world!")
|
print("Hello, world!")
|
||||||
|
@ -23,17 +23,28 @@ Links
|
||||||
Remove
|
Remove
|
||||||
^^^^^^
|
^^^^^^
|
||||||
|
|
||||||
.. code:: python3
|
.. code-block:: python3
|
||||||
|
|
||||||
import shutil
|
import shutil
|
||||||
shutil.rmtree(path)
|
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
|
Web
|
||||||
---
|
---
|
||||||
|
|
||||||
Get
|
Get
|
||||||
^^^
|
^^^
|
||||||
|
|
||||||
.. code:: python3
|
.. code-block:: python3
|
||||||
|
|
||||||
requests.get(url).content.decode(charset)
|
requests.get(url).content.decode(charset)
|
||||||
|
|
Loading…
Reference in a new issue