文字列の引数を関数に渡そうとしています。関数は、関数全体で変数として使用されます。どういうわけか、これをやろうとするとうまくいきません。私は何が間違っているのですか?
import subprocess
def printerSetup(printer):
subprocess.call(r'Cscript c:/windows/System32/Printing_Admin_Scripts/en-US/Prnport.vbs -a -r "'printer'.print.web.com" -h "' + printer + '.print.web.com" -o raw')
if printer == 'saturn' or printer == 'jupiter' or printer == 'neptune':
subprocess.call(r'rundll32 printui.dll, PrintUIEntry /if /b "' + printer + '" /f w:\printers\toshibae3511\eng\est_c2.inf /r "' + printer + '.print.web.com" /m "TOSHIBA e-STUDIO Color PS3"')
if printer == 'mercury':
subprocess.call(r'rundll32 printui.dll, PrintUIEntry /if /b "' + printer + '" /f w:\printers\dell1720\drivers\print\dell1720\DKABJ740.inf /r "' + printer + '.print.web.com" /m "Dell Laser Printer 1720dn"')
printerSetup("neptune")
printerSetup("mercury")
プログラムを編集しました。この新しいものを実行しようとした後、次のエラーが発生します。
C:\Python27\Projects\Printer Setup>c:\python27\python.exe saturn.py
File "saturn.py", line 3
subprocess.call(r'Cscript c:/windows/System32/Printing_Admin_Scripts/en-US/P
rnport.vbs -a -r "'printer'.print.web.com" -h "' + printer + '.print.web.c
om" -o raw')
^
SyntaxError: invalid syntax