<h2>试验</h2>
<p>我针对监听<code>nc</code>运行了您的代码,python2.7抱怨对<code>telnetlib.Telnet(HOST, PORT , timeout, Debug)</code>的调用是错误的,参数<code>Debug</code>应该被省略。在</p>
<p>实际上,在<a href="https://docs.python.org/2/library/telnetlib.html" rel="nofollow noreferrer">documentation</a>中,调试参数不存在:</p>
<blockquote>
<p>Telnet.open(host[, port[, timeout]])</p>
<pre><code>Connect to a host. The optional second argument is the port number, which defaults to the standard Telnet port (23). The optional
</code></pre>
<p>timeout parameter specifies a timeout in seconds for blocking
operations like the connection attempt (if not specified, the global
default timeout setting will be used).</p>
<pre><code>Do not try to reopen an already connected instance.
Changed in version 2.6: timeout was added.
</code></pre>
</blockquote>
<p>不过,一旦修复了这个问题,telnet在原始模式下发送的命令与您的代码完全相同。这可能是一个奇怪的时机问题,但除此之外,它应该是有效的。在</p>
<p>为了安全起见,如果我是你的话,我还是会开tcpdump的。在</p>
<h2>旧答案</h2>
<p>您没有终止这些命令,因此它们不会被执行。<code>.write()</code><a href="https://docs.python.org/2/library/telnetlib.html" rel="nofollow noreferrer">does not auto-terminate</a>命令。在</p>
<pre><code>tn.write('FREQ 1.92ghz' + "\n")
</code></pre>
<p>另外,在关门前等待答复,以防万一。在</p>
^{pr2}$