擅长:python、mysql、java
<p>这个定义有点笨拙和不令人满意,但我认为它解决了您的问题,而不必安装任何新的软件包。如果我创建一个模块<a href="http://code.activestate.com/recipes/134892/" rel="nofollow">defined in this link</a>(我把它放在一个名为格奇派瑞,我们可以检查输入键是否与字符串列表中的任何内容匹配。你知道吗</p>
<pre><code>from getch import getch
while True:
if getch() in ['l', 'r', 'L', 'R']:
print('This was the key I was looking for!')
</code></pre>
<p>从技术上讲,您只需要我链接到的类中与您的操作系统相关的部分,但是我链接到的这个示例<code>getch()</code>函数很好,因为它是跨平台的。你知道吗</p>