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

TGINSIGHT SIMILAR POSTS

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

Изворен канал @pythonotes · Post #191 · 14 дек.

Как разделить строку с shell-командой на отдельные аргументы в виде списка? Если сделать просто сплит по пробелу то получим то что надо, кроме случаев со вставками текста с пробелами. Например так: >>> '-arg "I Am Groot"'.split(' ') ['-arg', '"I', 'Am', 'Groot"'] Чтобы учитывать текст в кавычках как единый аргумент можно воспользоваться функцией shlex.split() Кто читает мой канал давно, уже в курсе. А что делать, если нужно обратное действие? Объединить аргументы из списка в строку и при этом добавить кавычки в аргумент с пробелами. Конечно, если вы используете subprocess то он сам всё разрулит. Но если вам нужна именно команда одной строкой, то можно воспользоваться готовой функцией в том же subprocess. >>> from subprocess import list2cmdline >>> list2cmdline(['-arg', 'I Am Groot']) '-arg "I Am Groot"' Он также позаботится об экранировании уже имеющихся кавычек >>> list2cmdline(['-arg', 'I Am "Groot"']) '-arg "I Am \"Groot\""' А вот так он может "схлопнуть" в команду JSON >>> list2cmdline(['--json', json.dumps({'key': 'value'})]) '--json "{\"key\": \"value\"}"' _______________ Возможно кто-то спросит, а зачем соединять аргументы в строку если subprocess сам это сделает а os.system не наш путь? Мне как-то потребовалось отправлять команду на удалённое выполнение и в API поддерживалось указание команды только строкой. Так что всякое бывает) #libs#basic

Hashtags

Резултати

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

Пребарај: #grpc

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

@githubtrending · Post #15049 · 12.08.2025 г., 12:00

#java#distributed_systems#durable_execution#grpc#java#javascript#microservice_orchestration#orchestration_engine#orchestrator#reactjs#spring_boot#workflow_automation#workflow_engine#workflow_management#workflows Conductor is an open-source tool that helps you manage and automate complex workflows involving many microservices and systems. It makes your workflows flexible, reliable, and scalable by handling retries, errors, and monitoring automatically. You can define workflows as code in JSON, use various task types, and manage workflows dynamically without tightly coupling services. It offers an easy-to-use web interface and supports multiple databases like Redis and MySQL. This helps you build, run, and monitor workflows efficiently, saving time and reducing errors in managing distributed applications. It also has SDKs for Java, Python, JavaScript, Go, and C# to integrate easily with your projects. https://github.com/conductor-oss/conductor

GitHub Trends

@githubtrending · Post #14904 · 03.07.2025 г., 12:00

#go#ai_assistant#ai_generated_code#cloud_native#code_generation#custom_templates#developer_tools#development_framework#gin#go_sponge#golang#grpc#grpc_gateway#low_code#microservice#protobuf#restful_api#sponge#web Sponge is a powerful Go development framework that helps you quickly build backend services like RESTful APIs and microservices with minimal coding. It generates modular Go code automatically by parsing SQL, Protobuf, and JSON files, letting you create complete backend projects through a simple web interface without complex commands. Sponge supports custom templates and integrates AI assistants (like ChatGPT) to help write business logic, greatly speeding up development and reducing repetitive work. It also offers full support for testing, API docs, and deployment, making your project more stable, efficient, and easier to maintain. This saves you time and improves code quality. https://github.com/go-dev-frame/sponge