PYTHON_SOLVES Telegram 55
## Работа с путями (`os` и `pathlib`)

Тема:
Как узнавать и менять расположение файлов.

import os
from pathlib import Path

print(os.getcwd()) # текущая папка
os.mkdir("new_folder") # создать папку

path = Path("example.txt")
print(path.exists()) # True если файл есть
print(path.is_file()) # True если файл
print(path.is_dir()) # True если папка


Полезные советы:

* pathlib удобен для кроссплатформенной работы с путями.
* Проверяй существование файлов перед чтением.

#азы



tgoop.com/python_solves/55
Create:
Last Update:

## Работа с путями (`os` и `pathlib`)

Тема:
Как узнавать и менять расположение файлов.

import os
from pathlib import Path

print(os.getcwd()) # текущая папка
os.mkdir("new_folder") # создать папку

path = Path("example.txt")
print(path.exists()) # True если файл есть
print(path.is_file()) # True если файл
print(path.is_dir()) # True если папка


Полезные советы:

* pathlib удобен для кроссплатформенной работы с путями.
* Проверяй существование файлов перед чтением.

#азы

BY Python решает 🐍


Share with your friend now:
tgoop.com/python_solves/55

View MORE
Open in Telegram


Telegram News

Date: |

Over 33,000 people sent out over 1,000 doxxing messages in the group. Although the administrators tried to delete all of the messages, the posting speed was far too much for them to keep up. Private channels are only accessible to subscribers and don’t appear in public searches. To join a private channel, you need to receive a link from the owner (administrator). A private channel is an excellent solution for companies and teams. You can also use this type of channel to write down personal notes, reflections, etc. By the way, you can make your private channel public at any moment. 2How to set up a Telegram channel? (A step-by-step tutorial) Ng was convicted in April for conspiracy to incite a riot, public nuisance, arson, criminal damage, manufacturing of explosives, administering poison and wounding with intent to do grievous bodily harm between October 2019 and June 2020. Concise
from us


Telegram Python решает 🐍
FROM American