@Learn_English_from_Zero_to_Hero · Post #60680 · 31.03.2026 г., 18:01
#Expressions
Hashtags
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
Пребарај: #expressions
@Learn_English_from_Zero_to_Hero · Post #60680 · 31.03.2026 г., 18:01
#Expressions
Hashtags
@Learn_English_from_Zero_to_Hero · Post #60602 · 26.01.2026 г., 16:56
#Expressions 💥Throw sb off 'course : 🔅if sb/sth is thrown off course, they are forced away from the direction they should be travelling in: ▪️ The plane was thrown off course. 2🔅to force sb to change the direction in which their ideas or actions are moving: ▪️ The government was thrown off course by economic problems.
Hashtags
@Learn_English_from_Zero_to_Hero · Post #60131 · 23.08.2025 г., 18:19
#Expressions 💥Fly the coop. ▪️ (idiomatic) Leave or escape. 💥Once she heard the teacher's voice, she flew the coop .
Hashtags
@Learn_English_from_Zero_to_Hero · Post #60129 · 23.08.2025 г., 18:14
#Expressions 💥Doom and gloom (uncountable) ▪️Something considered indicative of feelings of pessimism and despair. ▪️Antonyms: rainbows and unicorns, sunshine and rainbows. ⚡️The economic forecast contained the usual doom and gloom. ⚡️His sister was all doom and gloom after she lost the part.
Hashtags
@Learn_English_from_Zero_to_Hero · Post #60128 · 23.08.2025 г., 18:12
#Expressions 💥No great shakes (uncountable) ▪️(idiomatic) Something unexceptional, not noteworthy or special. ▪️Synonyms: nothing to write home about ⚡️You're welcome to stay here, but this hut ain't no great shakes for such as you.
Hashtags
@Learn_English_from_Zero_to_Hero · Post #59967 · 30.07.2025 г., 19:01
#Expressions 💥raring to do something (BrE) ● very eager to do something ⚜The children were raring to get outdoors.
Hashtags
@Learn_English_from_Zero_to_Hero · Post #59966 · 30.07.2025 г., 19:01
#Expressions 💥on the brink ●(idiomatic) Very nearly; imminent; close. ⚜The old building seemed to be on the brink of collapse.
Hashtags
@Learn_English_from_Zero_to_Hero · Post #59965 · 30.07.2025 г., 19:01
#Expressions 🔘on the level ▪️(idiomatic) Honest(ly), sincere(ly), straightforward(ly), fair(ly). 🔸He looks like a used car salesman, but he's really on thelevel, so you can trust him.
Hashtags
@Learn_English_from_Zero_to_Hero · Post #59936 · 24.07.2025 г., 19:00
#Expressions 💥Finer things ●That which is considered of a high quality, expensive or tasteful. •Example: ⚡️I'm not materialistic, though I do enjoy the finer things in life.
Hashtags
@Learn_English_from_Zero_to_Hero · Post #59935 · 24.07.2025 г., 19:00
#Expressions 💥Lose sleep over something •to worry about something •Example: ⚡️I know she's angry with me, but I'm not losing any sleep over it.
Hashtags
@Learn_English_from_Zero_to_Hero · Post #59934 · 24.07.2025 г., 19:00
#Expressions 💥Take the plunge •to do something important or difficult, especially after thinking about it for a long time. ●Example: ⚡️We're finally going to take the plunge and buy a house.
Hashtags
@Learn_English_from_Zero_to_Hero · Post #59909 · 23.07.2025 г., 06:16
#Expressions 💥Lend itself to sth FORMAL •to be suitable for a particular purpose •Example: ⚡️The novel's complex, imaginative style does not lend itself to translation.
Hashtags