打開文件可在當前工作目錄下的Temp文件夾中的蟒蛇打開文件Python中PWDIR的文件夾,通過AppleScript的
我試圖
pwdir=os.getcwd()
tempdir=pwdir+"/temp/test.txt"
f=open(tempdir,'r+')
當我打印TEMPDIR的路徑,它顯示了正確並且還讀取文件的內容。
當我嘗試從調用此python腳本的Applescript中結合此操作時。我得到這樣
f=open(pwdir1,'r+')
IOError: [Errno 2] No such file or directory: '//temp/test.txt'" number 1
編輯錯誤:
我使用shell腳本從AppleScript的調用這個pythonscript
do shell script "/Users/mymac/Documents/'Microsoft User Data'/test.py"
編輯:
Python代碼:
tempdir = os.path.join(os.getcwd(),'temp','htmlinput.html')
print tempdir
with open(tempdir) as f:
html=f.read()
Pyt (輸出完全正常)
/Users/mymac/Documents/Microsoft User Data/Outlook Script Menu Items/temp/htmlinput.html
我也能夠看到文件內容。
的AppleScript代碼:
do shell script "/Users/mymac/Documents/'Microsoft User Data'/'Outlook Script Menu Items'/new.py"
AppleScript的錯誤:
error "Microsoft Outlook got an error: Traceback (most recent call last):
File \"/Users/mymac/Documents/Microsoft User Data/Outlook Script Menu Items/new.py\", line 12, in <module>
with open(tempdir) as f:
IOError: [Errno 2] No such file or directory: '/temp/htmlinput.html'" number 1
@eryksun同樣的問題之一..已更新問題 – thinkcool
@eryksun打印錯誤 – thinkcool
嘗試@eryksun建議的或我在編輯中建議的內容。 Eryksun,你需要更頻繁地發佈答案,而不是評論,所以我可以upvote你。 – agf