|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
--- |
|
|
|
|
title: Python 3 cheatsheet |
|
|
|
|
tags: [python3, python, cheatsheet] |
|
|
|
|
updated: 2020-07-14 11:12 |
|
|
|
|
updated: 2020-07-21 17:58 |
|
|
|
|
description: A series of instructions in Python I use frequently on several projects |
|
|
|
|
--- |
|
|
|
|
|
|
|
|
@ -43,3 +43,5 @@ This is a list of instructions I use frequently in:
|
|
|
|
|
| get last path component from url | `pathlib.Path(urllib.parse.urlsplit(url: str).path).name` | `import pathlib, urllib` | |
|
|
|
|
| get relative path | `pathlib.Path(shlex.quote(path: str)).name` | `import pathlib, shlex` | |
|
|
|
|
| get full path | `str(pathlib.Path(shlex.quote(directory: str), shlex.quote(file: str)))` | `import pathlib, shlex` | |
|
|
|
|
| remove file extension | `pathlib.Path(shlex.quote(path: str)).stem` | `import pathlib, shlex` | |
|
|
|
|
| get file extension | `pathlib.Path(shlex.quote(path: str)).suffix` | `import pathlib, shlex` | |
|
|
|
|