我在python中编码,我有两个python文件。 在第一个中我做了:
import cgi, cgitb, os
export REMOTE_ADDR
def main(addr, name):
t = open('recei.py').read()
having = string.Template(template).substitute(
name = name,
addr = cgi.escape(os.environ["REMOTE_ADDR"])
)
在第二个python文件中我有我的HTML代码(我只放了表单的一部分):
<form name="sendData" method="get" action="echo ${addr}">
但我有大错误:
File "./send.py", line 12, in <module>
main(addr, name)
File "./send.py", line 45, in main
addr = cgi.escape(os.environ["REMOTE_ADDR"])
File "/usr/lib/python2.6/UserDict.py", line 22, in __getitem__
raise KeyError(key)
KeyError: 'REMOTE_ADDR'