黑马程序员技术交流社区

标题: 【广州Python】pygame中调用pygame.display.set_mode()方法参数... [打印本页]

作者: Leo06    时间: 2018-10-18 10:35
标题: 【广州Python】pygame中调用pygame.display.set_mode()方法参数...
本帖最后由 Leo06 于 2018-10-22 23:02 编辑

在调用 pygame.display.set_mode()的时候,如果是用关键字参数,会出现错误 :TypeError: set_mode() takes no keyword arguments
但是在其他的地方,用到关键字参数却没有出现错误,为什么会这样呢?

经题主查阅原因如下:
因为这是Python有些底层API直接调用的C,所以没有实现一些Python的特性,只能靠位置来判断参数,这样能最大的获得接近于C的性能

以下附上出现错误代码:
[AppleScript] 纯文本查看 复制代码
import pygame
pygame.init()

screen = pygame.display.set_mode(resolution=(470, 700))

while True:
    pass
pygame.quit()



import pygame
pygame.init()

screen = pygame.display.set_mode(resolution=(470, 700))

while True:
    pass
pygame.quit()






欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2