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

Резултати

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

Пребарај: #writer

当前筛选 #writer清除筛选

🗓🇿🇦November 20 marks the birthday of Nadine Gordimer (1923–2014), one of South Africa’s most influential English-language writers. 🏅 Recipient of the 1991 Nobel Prize in Literature. ✊ A committed member of the African National Congress and an active voice in the struggle against apartheid. ⚖️ In 1964, Gordimer helped prepare Nelson Mandela’s defense speech for the Rivonia Trial. 📖 While in prison, Mandela wrote: “I read all of Nadine Gordimer’s novels that were not banned.” ✍️ In 1987, she played a key role in establishing the Congress of South African Writers (COSAW), an important cultural platform during the final years of apartheid. 🌍 Her work remains a powerful testament to the pursuit of freedom, justice, and human dignity. 📸 Photo: Wikipedia #SouthAfrica#Literature#NobelPrize#Writer#HumanRights#History

iGaming Freelance Content Writers/Translators (Native Speakers) #remote#удаленно#iGaming#content#writer#tango We’re looking for iGaming Freelance Content Writers/Translators (Native Speakers). Our digital holding is expanding and we’re looking for native Filipino speaking translators & writers for iGaming projects. You’re a perfect fit if you have: • 1+ year of proven experience in iGaming translation or content writing • Solid understanding of iGaming terminology and cultural specifics of your region • Native fluency in #Filipino + strong English (for reading source materials) • Ability to start immediately and meet deadlines reliably What you’ll do: • Translate and localize website content (JSON format) from English • Adapt texts considering cultural/linguistic nuances • Proofread and edit content as needed We offer: • Fully remote freelance / part-time work • Competitive rates (based on skills and experience) • Interesting tasks and professional team support • No test task – we trust your portfolio Let’s connect! ⏺Apply: @IvanRecruiter ➖➖➖➖➖➖➖➖➖➖➖ 🪩 Откликнуться быстрее других ➖➖➖➖➖➖➖➖➖➖➖

Desi Memes Funny Jokes

@DESI_MEMES_Funny_Jokes · Post #5485 · 19.10.2024 г., 11:09

. . . . . #attitude#explore#tranding#reelsinstagram#viwe#relatable#exploreindia#relationshipquotes#reelkarofeelkaro#reelsolve#writer#lovereel#motivationlife#motivationalquotes#exploreing#explorepage#brokenheart#sayari#feelitreelit#reelslovers#exploreindonesia#exploreindia#100kfollowers#instagram#fashion#foryou#viralreels