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

Резултати

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

Пребарај: #servers

当前筛选 #servers清除筛选
djangoproject

@djangoproject · Post #196 · 28.11.2016 г., 03:42

http://asyncio.readthedocs.io/en/latest/webscraper.html #Web#scraping means downloading multiple web pages, often from different #servers. Typically, there is a considerable waiting time between sending a request and receiving the answer. Using a client that always waits for the server to answer before sending the next request, can lead to spending most of time waiting. Here asyncio can help to send many requests without waiting for a response and collecting the answers later. The following examples show how a synchronous client spends most of the time waiting and how to use asyncio to write asynchronous client that can handle many requests concurrently.

djangoproject

@djangoproject · Post #327 · 30.04.2017 г., 01:28

https://www.tutorialspoint.com/python/python_networking.htm Python provides two levels of access to network services. At a low level, you can access the basic #socket support in the underlying operating system, which allows you to implement #clients and #servers for both connection-oriented and connectionless protocols.

djangoproject

@djangoproject · Post #559 · 25.01.2018 г., 09:12

https://github.com/mehrdadrad/pubdns pubdns is a library for python to have more than 28K public #dns#servers from 190+ countries at your #python script. it works based on the public-dns.info collected data and there is a wrapper based on the dnspython to resolve all type of dns records through these public dns server smoothly. #imp

djangoproject

@djangoproject · Post #463 · 10.10.2017 г., 14:08

https://uwsgi-docs.readthedocs.io/en/latest/ The uWSGI project The #uWSGI project aims at developing a full stack for building #hosting services. Application #servers (for various programming languages and protocols), proxies, process managers and monitors are all implemented using a common #api and a common configuration style. #python

djangoproject

@djangoproject · Post #437 · 11.09.2017 г., 19:13

https://httpie.org/ #HTTPie consists of a single http command designed for painless debugging and interaction with HTTP #servers, #RESTful#APIs, and web services: Sensible defaults Expressive and intuitive command syntax Colorized and formatted terminal output Built-in JSON support Persistent sessions Forms and file uploads HTTPS, proxies, and authentication support Support for arbitrary request data and headers Wget-like downloads Extensions Linux, Mac OSX, and Windows support And more…

GitHub Trends

@githubtrending · Post #15116 · 03.09.2025 г., 12:00

#other#ai#anthropic_claude#awesome#context#mcp#model_context_protocol#servers#tool_use#tools Model Context Protocol (MCP) is an open standard that lets AI models securely connect to various data sources and tools, like files, databases, APIs, and cloud services, to get real-time, relevant information. This helps AI give more accurate, up-to-date, and context-aware answers, reducing repeated data processing and improving efficiency. MCP also supports automation of complex workflows and integration with many platforms, making AI more powerful and flexible. However, running MCP servers requires careful security measures to avoid risks like unauthorized code execution. Using MCP can save time, reduce costs, and enhance AI capabilities for tasks like chatbots, data analysis, and system control. https://github.com/appcypher/awesome-mcp-servers