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

Резултати

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

Пребарај: #ypip2026

当前筛选 #ypip2026清除筛选
⚡️ Youth

@youth_fvm · Post #2785 · 05.10.2025 г., 18:10

🌟 Applications for YPIP 2026 are NOW OPEN! 🌟 Are you ready to launch your professional journey next summer? The Young Professional Internships Program (YPIP) provides university students from Uzbekistan the opportunity to strengthen their professional skills through summer internships with leading companies, NGOs, and organizations in Tashkent. ✅ Participants will: - Gain hands-on work experience in business, STEM, and other fields - Take part in professional development workshops and field trips - Network with peers, mentors, and industry leaders - Receive guidance from established professionals 🌠 Eligibility: - Commitment to a career in business or STEM - Citizens of Uzbekistan, currently residing in the country - Enrolled at a local university as a 3rd or 4th-year student, or graduating by May 2026 - Proficiency in English ⏰ Application Deadline: December 8, 2025 🔗Link to the application Young Professional Internships Program (YPIP) is funded by the U.S. Embassy in Tashkent and implemented by American Councils for International Education. #YPIP2026#Internships#YouthOpportunities

IUT Career Centre

@iutcareercenter · Post #1741 · 28.10.2025 г., 05:57

🎓Applications for YPIP 2026 are NOW OPEN! Are you ready to launch your professional journey next summer? The Young Professional Internships Program (YPIP) provides university students from Uzbekistan the opportunity to strengthen their professional skills through summer internships with leading companies, NGOs, and organizations in Tashkent. 🟣Participants will: - Gain hands-on work experience in business, STEM, and other fields - Take part in professional development workshops and field trips - Network with peers, mentors, and industry leaders - Receive guidance from established professionals ✔️Eligibility: - Commitment to a career in business or STEM - Citizens of Uzbekistan, currently residing in the country - Enrolled at a local university as a 3rd or 4th-year student, or graduating by May 2026 - Proficiency in English ⏰ Application Deadline: December 8, 2025 📌Link to the application Young Professional Internships Program (YPIP) is funded by the U.S. Embassy in Tashkent and implemented by American Councils for International Education. #YPIP2026#Internships#YouthOpportunities