我刚刚将我的 python 从 3.9.1 更新到 3.9.4。当我尝试运行服务器时。控制台为此给了我一个警告:
WARNINGS:
learning_logs.Entry: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the LearningLogsConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
learning_logs.Topic: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the LearningLogsConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
No changes detected in app …Run Code Online (Sandbox Code Playgroud) 我试图使红色矩形向右移动,通过使用 pygame.move.rect 或 .blit,我能够完成同样的事情。我可以显示红色矩形并通过按右箭头将其移动到右侧。但是,我应该知道这两个函数之间有什么区别吗?为什么有两个函数基本上做同样的事情。
使用 pygame.move.rect 进行代码
import pygame
import sys
pygame.init()
#obtain the surface and rect for screen
screen_surface = pygame.display.set_mode((1200,800))
pygame.display.set_caption("Hi")
#Obtain Surface and rect for the rectangle
red_rectangle = pygame.Surface((600,400))
red_rectangle_rect = red_rectangle.get_rect()
#make the rectangle surface red
red_rectangle.fill((255,0,0))
move_right = False
while True:
#event loop
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_RIGHT:
move_right = True
print(event.type)
print(event.key)
elif event.type == pygame.KEYUP:
if event.key == pygame.K_RIGHT:
move_right …Run Code Online (Sandbox Code Playgroud)