TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #309 · 2 фев.

Метод строки split() разделяет строку на несколько строк по указанному символу >>> "a_b_c".split('_') ['a', 'b', 'c'] Можно указать максимальное количество разделений >>> "a_b_c".split('_', 1) ['a', 'b_c'] Или резать с другой стороны с помощью rsplit() (right split) >>> "a_b_c".rsplit('_', 1) ['a_b', 'c'] А что будет если оставить аргументы пустыми? >>> "a_b_c".split() ['a_b_c'] Получаем список с одним элементом, потому что по умолчанию используется пробельный символ. >>> "a b c".split() ['a', 'b', 'c'] То есть это равнозначно такому вызову? >>> "a b c".split(" ") ['a', 'b', 'c'] Кажется да, но нет! Давайте попробуем добавить пробелов между буквами >>> "a b c".split(" ") ['a', '', '', 'b', '', '', 'c'] И вот картина уже не так предсказуема 😕 А вот что будет по умолчанию >>> "a b c".split() ['a', 'b', 'c'] Всё снова красиво! 🤩 По умолчанию в качестве разделителя используется любой пробельный символ, будь то табуляция или новая строка. Включая несколько таких символов идущих подряд. А также игнорируются пробельные символы по краям строки. >>> "a\t b\n c ".split() ['a', 'b', 'c'] Аналогичный способ можно собрать с помощью регулярного выражения. Но пробелы по краям строки придется обрабатывать дополнительно. >>> import re >>> re.split(r"\s+", ' a b c '.strip()) ['a', 'b', 'c'] Здесь тоже можно указать количество разделений >>> re.split(r"\s+", 'a b c', 1) ['a', 'b c'] А что если мы хотим написать красиво, то есть split() без аргументов, но при этом указать количество разделений? В этом случае первым аргументом передаём None >>> "a\n b c".split(None, 1) ['a', 'b c'] Данный метод не учитывает строки с пробелами, взятые в кавычки 'a "b c" '.split() ['a', '"b', 'c"'] Но для таких случаев есть другие способы. #tricks#basic

Резултати

Пронајдени 4 слични објави

Пребарај: #filesystem

当前筛选 #filesystem清除筛选
GitHub Trends

@githubtrending · Post #14657 · 01.05.2025 г., 14:30

#c_lang#embedded#filesystem#microcontroller LittleFS is a file system designed for small devices like microcontrollers. It helps keep your data safe even if the power goes off suddenly. This is because it uses a "copy-on-write" system, which means it doesn't overwrite old data until the new data is safely stored. LittleFS also helps extend the life of your storage by spreading out writes across different areas, a process called wear leveling. This makes it very reliable and efficient for devices with limited memory and storage. https://github.com/littlefs-project/littlefs

GitHub Trends

@githubtrending · Post #14917 · 05.07.2025 г., 13:00

#rust#bigdata#cloud_native#distributed_systems#filesystem#minio#object_storage#oss#rust#s3 RustFS is a fast and safe distributed object storage system built with Rust, offering high performance and scalability for large data needs like AI and big data. It is compatible with S3, easy to use, and open source under the business-friendly Apache 2.0 license. Compared to others like MinIO, RustFS provides better memory safety, no risky data logging, and supports local cloud providers. You can quickly install it via a script or Docker, manage storage through a simple web console, and benefit from a strong community and detailed documentation. This makes RustFS a reliable, cost-effective choice for secure, scalable storage. https://github.com/rustfs/rustfs

GitHub Trends

@githubtrending · Post #15561 · 14.03.2026 г., 12:30

#python#agent#agentic_rag#ai_agents#clawbot#context_database#context_engineering#filesystem#llm#memory#openclaw#opencode#rag#skill OpenViking is a free open-source tool that acts as a context database for AI agents, using a simple file system to organize memories, resources, and skills under viking:// paths. It fixes issues like scattered data, high token costs, weak searches, and untraceable errors with tiered loading (L0 abstracts, L1 overviews, L2 details loaded on demand), recursive directory retrieval, visual traces, and auto-session memory updates. You benefit by building smarter, cheaper agents faster—like managing files—saving up to 96% on tokens while boosting task success by 50%+. https://github.com/volcengine/OpenViking