python 중국어 인터페이스 인 스 턴 스 설정 방법
먼저 실례 코드 를 보 여 줍 니 다:
import pygame
from pygame.locals import *
def main():
pygame.init()
screen = pygame.display.set_mode((1000, 450)) #
pygame.display.set_caption('pygame ') # ,
background = pygame.Surface(screen.get_size())
background = background.convert()
background.fill((250, 250, 250))
font = pygame.font.Font(None, 60) # , ,
#font = pygame.font.Font('/home/xgj/Desktop/simsun/simsun.ttf', 60) # ,
text = font.render("Hello ", 1, (10, 10, 10))
textpos = text.get_rect()
textpos.center = background.get_rect().center
background.blit(text, textpos)
screen.blit(background, (0, 0))
pygame.display.flip()
while 1:
for event in pygame.event.get():
if event.type == QUIT:
return
screen.blit(background, (0, 0))
pygame.display.flip()
if __name__ == '__main__': main()
실행 효과 표시:![](https://s1.md5.ltd/image/59a1ccd4973a9e97d031cdd6b8783cd3.png)
메모:hello 뒤 에는 어 지 러 운 코드 입 니 다.중국어 내용 은'사랑 해'가 표시 되 지 않 았 습 니 다.
수 정 된 코드 표시:
import pygame
from pygame.locals import *
def main():
pygame.init()
screen = pygame.display.set_mode((1000, 450)) #
pygame.display.set_caption('pygame ') # ,
background = pygame.Surface(screen.get_size())
background = background.convert()
background.fill((250, 250, 250))
#font = pygame.font.Font(None, 60) # , ,
font = pygame.font.Font('/home/xgj/Desktop/simsun/simsun.ttf', 60) # ,
text = font.render("Hello ", 1, (10, 10, 10))
textpos = text.get_rect()
textpos.center = background.get_rect().center
background.blit(text, textpos)
screen.blit(background, (0, 0))
pygame.display.flip()
while 1:
for event in pygame.event.get():
if event.type == QUIT:
return
screen.blit(background, (0, 0))
pygame.display.flip()
if __name__ == '__main__': main()
실행 효과 표시:![](https://s1.md5.ltd/image/728ac3e9c29f684e2bfc517e30e6085e.png)
위 에서 보 듯 이 이미 중국어 가 나 왔 다.
요약:중국어 가 포 함 된 글꼴 을 다운로드 해 야 합 니 다.예 를 들 어 simsun.ttf\#지정 한 파일 디 렉 터 리 에 두 어야 합 니 다.
python 이 중국어 인터페이스 인 스 턴 스 를 설정 하 는 방법 에 관 한 이 글 은 여기까지 소개 되 었 습 니 다.python 이 중국어 인터페이스 를 설정 하 는 방법 에 관 한 내용 은 예전 의 글 을 검색 하거나 아래 의 관련 글 을 계속 찾 아 보 세 요.앞으로 저 희 를 많이 사랑 해 주세요!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
로마 숫자를 정수로 또는 그 반대로 변환그 중 하나는 로마 숫자를 정수로 변환하는 함수를 만드는 것이었고 두 번째는 그 반대를 수행하는 함수를 만드는 것이었습니다. 문자만 포함합니다'I', 'V', 'X', 'L', 'C', 'D', 'M' ; 문자열이 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.