3
我正在運行下面的python腳本。運行腳本時發生Python KeyError
import cgi
import os
import time
import sys
import yate
print(yate.start_response('text/plain'))
addr=os.environ['REMOTE_ADDR']
host=os.environ['REMOTE_HOST']
method=os.environ['REQUEST_METHOD']
cur_time=time.asctime(time.localtime())
print(host+","+addr+","+cur_time+":"+method+":",end='',file=sys.stderr)
我得到了下面的錯誤。
addr=os.environ['REMOTE_ADDR']
File "C:\Python33\lib\os.py", line 676, in __getitem__
raise KeyError(key) from None
KeyError: 'REMOTE_ADDR'
請幫助這個....
唉......謝謝你......不好意思在這裏問這種啞巴qns ...... :-) –