0
這是代碼,我遇到的問題是,儘管一切按預期工作,除非指定完整的文件路徑(如在「s」中),否則不能調用所需的perl腳本。 ,即使它們都在同一個目錄(桌面)中。任何幫助,將不勝感激。從python調用perl沒有完整的文件路徑
import subprocess
status = ['s', 'mj', 'ms', 'h','q']
while(1):
while(1):
print("Compute income tax: \n")
print("\ts = single \n")
print("\tmj = married and filing jointly \n")
print("\tms = married and filing seperately \n")
print("\th = head of household \n")
print("\tq = quit \n")
#get user input for status
choice=raw_input("Enter status: ")
if (choice in status):
print("58")
break
else:
print("Unknown status!")
if (choice=='q'):
break
else:
if (choice=="s"):
subprocess.call('perl C:/Users/Username/Desktop/single.pl')
elif(choice=='mj'):
subprocess.call('perl marriedJointly.pl')
elif(choice=='ms'):
subprocess.call('perl marriedSeperately.pl')
elif(choice=='h'):
subprocess.call('perl head.pl')
#and so on
呃,不,我打開命令提示符窗口並輸入完整的文件路徑並執行它。我打開cmd並將文件拖到窗口中,然後按回車。 – user2167980
哦,明白了,這是其他文件的問題,謝謝你的幫助。 – user2167980