Telegram Group & Telegram Channel
This media is not supported in your browser
VIEW IN TELEGRAM
🖥 Совет по Python:


from pathlib import Path

# Создаем объект Path для заданного пути к файлу
path = Path("C:/Users/test.md")

# Получаем имя файла вместе с расширением
print(path.name) # 'test.md'

# Получаем только имя файла без расширения
print(path.stem) # 'test'

# Получаем расширение файла (с точкой)
print(path.suffix) # '.md'

# Получаем родительскую директорию (папку)
print(path.parent) # 'C:/Users'

С помощью модуля pathlib вы можете получать различные части пути — имя файла, расширение, родительскую директорию. Это упрощает работу с файловыми путями и их анализ.

Объяснение:

- path.name — возвращает полное имя файла (например, test.md).

- path.stem — возвращает имя файла без расширения (например, test).

- path.suffix — возвращает расширение файла (например, .md).

- path.parent — возвращает путь к родительской директории (например, C:/Users).

Модуль pathlib позволяет удобно разбирать путь к файлу на части и работать с ними, не используя строковые операции вручную. Это особенно полезно для кроссплатформенной работы с файлами и папками.

@pythonl
Please open Telegram to view this post
VIEW IN TELEGRAM



tg-me.com/pythonl/4886
Create:
Last Update:

🖥 Совет по Python:


from pathlib import Path

# Создаем объект Path для заданного пути к файлу
path = Path("C:/Users/test.md")

# Получаем имя файла вместе с расширением
print(path.name) # 'test.md'

# Получаем только имя файла без расширения
print(path.stem) # 'test'

# Получаем расширение файла (с точкой)
print(path.suffix) # '.md'

# Получаем родительскую директорию (папку)
print(path.parent) # 'C:/Users'

С помощью модуля pathlib вы можете получать различные части пути — имя файла, расширение, родительскую директорию. Это упрощает работу с файловыми путями и их анализ.

Объяснение:

- path.name — возвращает полное имя файла (например, test.md).

- path.stem — возвращает имя файла без расширения (например, test).

- path.suffix — возвращает расширение файла (например, .md).

- path.parent — возвращает путь к родительской директории (например, C:/Users).

Модуль pathlib позволяет удобно разбирать путь к файлу на части и работать с ними, не используя строковые операции вручную. Это особенно полезно для кроссплатформенной работы с файлами и папками.

@pythonl

BY Python/ django


Share with your friend now:
tg-me.com/pythonl/4886

View MORE
Open in Telegram


Python django Telegram | DID YOU KNOW?

Date: |

Traders also expressed uncertainty about the situation with China Evergrande, as the indebted property company has not provided clarification about a key interest payment.In economic news, the Commerce Department reported an unexpected increase in U.S. new home sales in August.Crude oil prices climbed Friday and front-month WTI oil futures contracts saw gains for a fifth straight week amid tighter supplies. West Texas Intermediate Crude oil futures for November rose $0.68 or 0.9 percent at 73.98 a barrel. WTI Crude futures gained 2.8 percent for the week.

How Does Bitcoin Work?

Bitcoin is built on a distributed digital record called a blockchain. As the name implies, blockchain is a linked body of data, made up of units called blocks that contain information about each and every transaction, including date and time, total value, buyer and seller, and a unique identifying code for each exchange. Entries are strung together in chronological order, creating a digital chain of blocks. “Once a block is added to the blockchain, it becomes accessible to anyone who wishes to view it, acting as a public ledger of cryptocurrency transactions,” says Stacey Harris, consultant for Pelicoin, a network of cryptocurrency ATMs. Blockchain is decentralized, which means it’s not controlled by any one organization. “It’s like a Google Doc that anyone can work on,” says Buchi Okoro, CEO and co-founder of African cryptocurrency exchange Quidax. “Nobody owns it, but anyone who has a link can contribute to it. And as different people update it, your copy also gets updated.”

Python django from br


Telegram Python/ django
FROM USA