我通過Add to python path mac os x看過,我認爲這樣做是個好主意,但IDLE仍然給我一個簡單的open(filename, mode)
調用的語法錯誤,所以我進一步觀察,發現我能夠按照http://developer.apple.com/library/mac/#qa/qa1067/_index.html中的說法操作,並在.MacOSX文件夾中設置了一個environment.plist,所以我在我的家庭目錄中做了這樣的操作,但仍然沒有改變...我現在丟失了:-)Mac OSX上的Pythonpath
那就是我添加的在.bash_profile中我的Python路徑,在我environment.plist相同的路徑(不包括:$ PYTHONPATH):
PYTHONPATH="/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7:$PYTHONPATH"
export PYTHONPATH
編輯: 多數民衆贊成在我得到的語法錯誤......在解釋工作正常
import xml.etree.ElementTree as et
import json
app = Bottle()
@app.route('/proPass', method ='POST')
#here happens here, need it further down in the code... which is not really relevant
f = open('/Users/mohi/Desktop/proPass_project/server_service/systems.xml', 'rw')
def getData():
timestamp = request.POST.get('timestamp', '').strip()
data = request.POST.get('data', '').strip()
if timestamp:
processData(data, timestamp)
run()
錯誤:
把準確和完整的回溯和錯誤放在'
'之間,這樣我們就可以確切地看到可能是什麼問題。另外,添加幾行上下文 - 通常錯誤出現在__before__其中一行檢測到錯誤的位置。 – agf