【環境】
CentOS7.4
Ubuntu16.04
Python3.5.2
#やりたいこと
abc&def
↓
abc&def
「&」という文字を「&」という文字へ変換したい
echo "abc&def" | sed -r 's/&/\&/g'
これで実現できます。
ただ、これをpythonのファイル上で実装したいのです。
#やったこと
import subprocess cmd = "echo \"abc&def\" | sed -r 's/&/\&/g'" a = subprocess.check_output(cmd, shell=True) print(a.decode('utf-8'))
結果
abc&def ↓ abc&def 変わらず・・・
なんとか、python上で実装したいのですがどうしたら実装できますでしょうか?
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/02/05 16:11