PYTHONPOOL Telegram 273
⚠️ Daily Python Facts ⚠️

An elegant way to deal with a file path (3.4≥)

>>> from pathlib import Path
>>> data_folder = Path("source_data/text_files/")

# Path calculation and metadata
>>> file_to_open = data_folder / "raw_data.txt"
>>> file_to_open.name
"raw_data.txt"
>>> file_to_open.suffix
"txt"
>>>file_to_open.stem
"raw_data"

# Files functions
>>> f = open(file_to_open)
>>> f.read()
# content of the file
>>> file_to_open.exists()
True


- @pythonpool -



tgoop.com/pythonpool/273
Create:
Last Update:

⚠️ Daily Python Facts ⚠️

An elegant way to deal with a file path (3.4≥)

>>> from pathlib import Path
>>> data_folder = Path("source_data/text_files/")

# Path calculation and metadata
>>> file_to_open = data_folder / "raw_data.txt"
>>> file_to_open.name
"raw_data.txt"
>>> file_to_open.suffix
"txt"
>>>file_to_open.stem
"raw_data"

# Files functions
>>> f = open(file_to_open)
>>> f.read()
# content of the file
>>> file_to_open.exists()
True


- @pythonpool -

BY Python Pool | Python Course | Machine Learning | Data Science Tutorials | Artificial Intelligence | Computer Science Programming


Share with your friend now:
tgoop.com/pythonpool/273

View MORE
Open in Telegram


Telegram News

Date: |

To delete a channel with over 1,000 subscribers, you need to contact user support Image: Telegram. End-to-end encryption is an important feature in messaging, as it's the first step in protecting users from surveillance. How to create a business channel on Telegram? (Tutorial) Co-founder of NFT renting protocol Rentable World emiliano.eth shared the group Tuesday morning on Twitter, calling out the "degenerate" community, or crypto obsessives that engage in high-risk trading.
from us


Telegram Python Pool | Python Course | Machine Learning | Data Science Tutorials | Artificial Intelligence | Computer Science Programming
FROM American