충분하지 인수를하지만 난 파이썬에 포함 할 때 점점 :파이썬 -이 라인 형식 오류 해결하는 방법이</p> <p>터미널 명령 줄에서의 작업을 형식 문자열
$ amixer -c2 | grep "Simple mixer control 'Mic',0" -A 5 | grep "Mono: " | sed -e 's/Capture /\n/g' | tail -1 | awk '{print $2}' | sed -e 's/%]//g' | sed -e 's/\[//g'
88
파이썬 :
tmp = "2"
a = """amixer -c%s | grep "Simple mixer control 'Mic',0" -A 5 | grep "Mono: " | sed -e 's/Capture /\n/g' | tail -1 | awk '{print $2}' | sed -e 's/%]//g' | sed -e 's/\[//g'""" % tmp
print "Reply " + a
a = os.popen(a).read()
print a
오류 :
Running: /var/tmp/p/test.py (Sun Dec 8 20:58:07 2013)
Traceback (most recent call last):
File "/var/tmp/p/test.py", line 2, in <module>
a = """amixer -c%s | grep "Simple mixer control 'Mic',0" -A 5 | grep "Mono: " | sed -e 's/Capture /\n/g' | tail -1 | awk '{print $2}' | sed -e 's/%]//g' | sed -e 's/\[//g'""" % tmp
TypeError: not enough arguments for format string
Execution Successful!
시도 : a = r ('amixer -c2 | grep "간단한 믹서 컨트롤'Mic ', 0"-A 5 | grep "모노 :"| sed -e'/ 캡처/\ n/g '| 꼬리 -1 | awk '{인쇄 $ 2}'| sed -e 's/%] // g'| sed -e 's/\ [// g' 88 '). 확실하지 않지만 원시 문자열은 트릭을해야합니다! – Vivek