2017-12-02 23:02:37 +01:00
|
|
|
Snippets
|
2019-08-06 09:30:14 +02:00
|
|
|
========
|
2017-12-02 23:02:37 +01:00
|
|
|
|
2019-08-06 09:30:14 +02:00
|
|
|
Hello world
|
|
|
|
-----------
|
2017-12-02 23:02:37 +01:00
|
|
|
|
2019-08-06 09:30:14 +02:00
|
|
|
.. code:: python3
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
print("Hello, world!")
|
|
|
|
|
2024-03-08 23:59:39 +01:00
|
|
|
Files
|
|
|
|
-----
|
|
|
|
|
|
|
|
Links
|
|
|
|
^^^^^
|
|
|
|
|
|
|
|
.. code-block:: python3
|
|
|
|
|
|
|
|
os.symlink('target', 'tmp_path')
|
|
|
|
os.replace('tmp_path', 'path')
|
2019-08-06 09:30:14 +02:00
|
|
|
|
|
|
|
Remove
|
|
|
|
^^^^^^
|
2017-12-02 23:02:37 +01:00
|
|
|
|
|
|
|
.. code:: python3
|
|
|
|
|
2019-08-06 09:30:14 +02:00
|
|
|
import shutil
|
|
|
|
shutil.rmtree(path)
|
2017-12-02 23:02:37 +01:00
|
|
|
|
|
|
|
Web
|
2019-08-06 09:30:14 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
Get
|
|
|
|
^^^
|
2017-12-02 23:02:37 +01:00
|
|
|
|
|
|
|
.. code:: python3
|
|
|
|
|
2019-08-06 09:30:14 +02:00
|
|
|
requests.get(url).content.decode(charset)
|