擅长:python、mysql、java
<p>您可以使用<code>pygame.display.Info()</code>:</p>
<p><a href="http://www.pygame.org/docs/ref/display.html#pygame.display.Info" rel="nofollow noreferrer">docs</a>说:</p>
<blockquote>
<p>current_h, current_w: Height and width of the current video mode, or of the
desktop mode if called before the display.set_mode is called.<br/>
(current_h, current_w are available since SDL 1.2.10, and pygame
1.8.0) They are -1 on error, or if an old SDL is being used.1.8.0)</p>
</blockquote>
<p><code>pygame.display.Info()</code>创建具有属性<code>current_h</code>和<code>current_w</code>的Info对象。
在调用<code>display.set_mode</code>之前创建Info对象,然后使用对象中的<code>current_h</code>和<code>current_w</code>调用<code>display.set_mode</code>。</p>
<p><strong>示例:</strong></p>
<pre><code>infoObject = pygame.display.Info()
pygame.display.set_mode((infoObject.current_w, infoObject.current_h))
</code></pre>