为什么python这个代码写出来的图片不显示? 50

为什么python这个代码写出来的图片不显示?importpygamefrompygame.spriteimportSpritefrompygame.spriteimpo... 为什么python这个代码写出来的图片不显示?import pygame from pygame.sprite import Sprite from pygame.sprite import Group import sys class Star(Sprite): """the class that represents a single star""" def __init__(self, screen): super().__init__ self.screen = screen # Load the image and obtain its rectangular. self.image = pygame.image.load('images\star.bmp') self.rect = self.image.get_rect() # Make every star show up at someplace near the left corner. self.rect.x = self.rect.width self.rect.y = self.rect.height def blitme(): self.screen.blit(self_screen, self.image) def get_number_stars_x(screen_width, star_width ): available_space_x = screen_width - 2 * star_width number_stars_x = int(available_space_x / 2 * star_width) return number_stars_x def get_number_rows(screen_height, star_height): available_space_y = screen_height - 2 * star_height number_rows = int(available_space_y / 2 * star_height) return number_rows def create_star(screen, stars, star_number, row_number): """Make one star and put it in the current line.""" star = Star(screen) star.x = star.rect.width + 2 * star.rect.width * star_number star.y = star.rect.height + 2 * star.rect.height * row_number stars.add(star) def create_bunch(screen, stars, screen_width, screen_height): star = Star(screen) number_stars_x = get_number_stars_x(screen_width, star.rect.width) number_rows = get_number_rows(screen_height, star.rect.height) for star_number in range(number_stars_x): for row_number in range(number_rows): create_star(screen, stars, star_number, row_number) def check_events(): for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() def show_stars(): screen_height = 675 screen_width = 1200 screen = pygame.display.set_mode((screen_width, screen_height)) bg_color = (255,255,255) pygame.display.set_caption("Stars") stars = Group() create_bunch(screen, stars, screen_width, screen_height) while True: screen.fill(bg_color) check_events() stars.draw(screen) pygame.display.flip() show_stars() 展开
 我来答
超无敌小蘑菇Bm
2018-05-12 · TA获得超过279个赞
知道小有建树答主
回答量:436
采纳率:0%
帮助的人:58万
展开全部
传入的 C:xxx 是目录,且存在?且下面有文件么?
Import os.path
对目录进行下判断吧: os.path.isdir
文件路径的拼装用os.path.join
读文件不用while,
for line in f:
print line
追问
目录里文件的...
目录里有文件的
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式