<p>在我之前的<a href="https://stackoverflow.com/questions/17095401/python-2-7-classes/17095610#17095610">question</a>之后。有人建议我创建一个单独的python库,然后导入它。在</p>
<p>在阅读了更多关于<code>Stackoverflow</code>的文章后,我意识到最好的方法是<a href="https://stackoverflow.com/questions/1186789/what-is-the-best-way-to-call-a-python-script-from-another-python-script">write methods</a>,我选择了这个方法。在</p>
<pre><code>def USB(port):
activateme = serial.Serial(port,115200)
#print "starting to monitor"
for line in activateme:
#print line
return line
def USBprocess(line):
if line.startswith( '#d'):
fields = line.split(',')
if len(fields) > 5:
W = fields[1]
V = fields[2]
A = fields[3]
print "monitoring"
return W,V,A
op = USB(port)
w,v,a = USBprocess(op)
</code></pre>
<p>我得到了一个错误:</p>
^{pr2}$
<p>我做错什么了?在</p>