擅长:python、mysql、java
<blockquote>
<p>I am importing a script trainstate.py which is in the same directory of the script I am running</p>
</blockquote>
<p>这并不意味着这个目录是您的web服务器进程的当前工作目录,也不意味着它在系统路径对于这个过程。thkang已经提供了最好的答案(我应该说的是相反的顺序),但是无论如何-试着用这个代码来代替,看看你得到了什么:</p>
<pre><code>import sys, os
print "Content-Type: text/html\n\n"
print "sys.path is : ", ", ".join(sys.path)
print "current working directory is : ", os.getcwd()
try:
# star imports are evil
from trainstate import TrainState
except Exception, e:
print "failed to import TrainState : %s" % e
else:
st = TrainState(784)
print st.get_state()
</code></pre>