あるフリーランスエンジニアの色んなメモ!! ITスキル・ライフハックとか

Python:文字列をshellの引数で使えるようにエスケープする

凡例

import shlex

shlex.quote(文字列)

※shellに渡す個々の引数に対して実行する必要がある

参考

shlex — 単純な字句解析
https://docs.python.org/ja/3/library/shlex.html#shlex.quote

comments powered by Disqus