Notice: file_put_contents(): Write of 16864 bytes failed with errno=28 No space left on device in /var/www/tgoop/post.php on line 50
Proglib.academy | IT-курсы@proglib_academy P.2723
PROGLIB_ACADEMY Telegram 2723
⚡️Команда дня: os.walk + fnmatch

Хотите быстро найти и обработать все файлы определенного типа на Python?
Вот минимальный скрипт:
import os
import fnmatch

for root, dirs, files in os.walk('.'):
for file in fnmatch.filter(files, '*.py'):
print(os.path.join(root, file))


➡️ Что делает:
— Рекурсивно обходит текущую директорию и все вложенные
— Ищет все файлы с расширением .py
— Выводит пути к найденным файлам

Добавьте проверку содержимого:
for root, dirs, files in os.walk('.'):
for file in fnmatch.filter(files, '*.py'):
path = os.path.join(root, file)
with open(path, 'r', encoding='utf-8') as f:
if 'TODO' in f.read():
print(path)


Proglib Academy
#буст
Please open Telegram to view this post
VIEW IN TELEGRAM
❤‍🔥11👾1



tgoop.com/proglib_academy/2723
Create:
Last Update:

⚡️Команда дня: os.walk + fnmatch

Хотите быстро найти и обработать все файлы определенного типа на Python?
Вот минимальный скрипт:

import os
import fnmatch

for root, dirs, files in os.walk('.'):
for file in fnmatch.filter(files, '*.py'):
print(os.path.join(root, file))


➡️ Что делает:
— Рекурсивно обходит текущую директорию и все вложенные
— Ищет все файлы с расширением .py
— Выводит пути к найденным файлам

Добавьте проверку содержимого:
for root, dirs, files in os.walk('.'):
for file in fnmatch.filter(files, '*.py'):
path = os.path.join(root, file)
with open(path, 'r', encoding='utf-8') as f:
if 'TODO' in f.read():
print(path)


Proglib Academy
#буст

BY Proglib.academy | IT-курсы


Share with your friend now:
tgoop.com/proglib_academy/2723

View MORE
Open in Telegram


Telegram News

Date: |

End-to-end encryption is an important feature in messaging, as it's the first step in protecting users from surveillance. Unlimited number of subscribers per channel Telegram message that reads: "Bear Market Screaming Therapy Group. You are only allowed to send screaming voice notes. Everything else = BAN. Text pics, videos, stickers, gif = BAN. Anything other than screaming = BAN. You think you are smart = BAN. Find your optimal posting schedule and stick to it. The peak posting times include 8 am, 6 pm, and 8 pm on social media. Try to publish serious stuff in the morning and leave less demanding content later in the day. Step-by-step tutorial on desktop:
from us


Telegram Proglib.academy | IT-курсы
FROM American