Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revisionLast revisionBoth sides next revision | ||
devwiki:python [2024/01/06 19:26] – [Python and interaction with other API] ying | devwiki:python [2024/03/21 08:53] – [Online Python run] ying | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | |||
+ | |||
+ | ====== Modern Python Practice ====== | ||
+ | |||
+ | * nowaday, now one use python 2.x anymore, use python 3 standard, use this | ||
+ | * use pathlib instead of os.path | ||
+ | * use f" | ||
Line 937: | Line 944: | ||
except OSError: | except OSError: | ||
pass | pass | ||
+ | | ||
+ | # method 3: all in one check and create if needed, like method 2 but not need try and except since it will be ok for exist | ||
+ | os.makedirs(os.path.dirname(output_path), | ||
</ | </ | ||
* write python data< | * write python data< | ||
Line 2399: | Line 2409: | ||
response = requests.get(url) | response = requests.get(url) | ||
</ | </ | ||
- | - now, you should have got the reply from your bot | + | - now, you should have got the reply from your bot <code python> |
+ | result = response.json() | ||
+ | send_state = result[' | ||
+ | send_result = result[' | ||
+ | # chat (first_name, | ||
+ | </ | ||