@QuietWorld · Post #6726 · 17.10.2019 г., 13:01
It's often just enough to be with someone. I don't need to touch them. Not even talk. A feeling passes between you both. You're not alone. – Marilyn Monroe #solitude@quietworld🍃
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
Пребарај: #solitude
@QuietWorld · Post #6726 · 17.10.2019 г., 13:01
It's often just enough to be with someone. I don't need to touch them. Not even talk. A feeling passes between you both. You're not alone. – Marilyn Monroe #solitude@quietworld🍃
Hashtags
@QuietWorld · Post #6722 · 16.10.2019 г., 23:30
I have to be alone very often. I'd be quite happy if I spent from Saturday night until Monday morning alone in my apartment. That's how I refuel. – Audrey Hepburn #solitude@quietworld🍃
Hashtags
@QuietWorld · Post #6714 · 15.10.2019 г., 08:30
A man can be himself only so long as he is alone. – Arthur Schopenhauer #solitude @quietworld🍃
Hashtags
@QuietWorld · Post #6705 · 14.10.2019 г., 08:30
If you make friends with yourself you will never be alone. – Maxwell Maltz #solitude#quotes @quietworld🍃
@QuietWorld · Post #6701 · 13.10.2019 г., 23:30
Alone let him constantly meditate in solitude on that which is salutary for his soul, for he who meditates in solitude attains supreme bliss. – Guru Nanak #solitude#quotes @quietworld🍃
@QuietWorld · Post #6700 · 13.10.2019 г., 13:00
"There's a tremendous difference between alone and lonely. You could be lonely in a group of people. I like being alone. I like eating by myself. I go home at night and just watch a movie or hang out with my dog. I have to exert myself and really say, oh God, I've got to see my friends 'cause I'm too content being by myself." - Drew Barrymore - #quotes#solitude @quietworld🍃
@QuietWorld · Post #6673 · 09.10.2019 г., 12:00
We visit others as a matter of social obligation. How long has it been since we have visited ourselves? #solitude#quotes @quietworld🍃
@QuietWorld · Post #6670 · 09.10.2019 г., 00:00
Solitude is a good place to visit but a poor place to stay. —Josh Billings – #solitude#quotes @quietworld🍃
@QuietWorld · Post #6668 · 08.10.2019 г., 12:00
When we cannot bear to be alone, it means we do not properly value the only companion we will have from birth to death — ourselves. – Morris Adler – #solitude#quotes @quietworld🍃
@QuietWorld · Post #6662 · 08.10.2019 г., 05:00
There's one thing worse than being alone – wishing you were. #solitude#quotes @quietworld🍃
@QuietWorld · Post #6688 · 11.10.2019 г., 08:30
Men go abroad to wonder at the heights of mountains, at the huge waves of the sea, at the long courses of the rivers, at the vast compass of the ocean, at the circular motions of the stars; and they pass by themselves.., without wondering. – St. Augustine – #solitude#quotes#reflection @quietworld🍃
Hashtags
@QuietWorld · Post #6654 · 07.10.2019 г., 04:39
You have to start knowing yourself so well that you begin to know other people – a piece of us is in every person we can ever meet. —John D. MacDonald – #quotes#solitude#reflection @quietworld🍃
Hashtags