我已经制作了一个程序,将文本转换为二进制代码,但它真的很混乱.这是我的代码:
def converter():
print("message:")
inputMsg = input()
msg = ''
for letter in inputMsg:
if letter == 'a':
msg = msg + '01100001'
elif letter == 'b':
msg = msg + '01100010'
elif letter == 'c':
msg = msg + '01100011'
elif letter == 'd':
msg = msg + '01100100'
elif letter == 'e':
msg = msg + '01100101'
elif letter == 'f':
msg = msg + '01100110'
elif letter == 'g':
msg = msg + '011000111'
elif letter == …
Run Code Online (Sandbox Code Playgroud) 我想获取像素的颜色值。我读过一些有关名为“pygame.Surface.get_at()”的函数的内容。但是当我使用这个函数时我得到这个错误:
Traceback (most recent call last):
pygame.Surface.get_at(300, 200)
TypeError: descriptor 'get_at' requires a 'pygame.Surface' object but received a 'int'
Run Code Online (Sandbox Code Playgroud) 我下载了一种名为 redline.ttf 的字体,我想在 pygame 中使用它。我只想在屏幕上打印文本。我在文件夹 pygame -> lib 中找到了一种名为“freesansbold.ttf”的基本字体。我已将下载的字体放在同一个文件夹中,但是当我使用
fontObj = pygame.font.Font('redline.ttf', 16)
textSurfaceObj = fontObj.render('some text', True, (240,240,240), (115,117,117))
textRectObj = textSurfaceObj.get_rect()
textRectObj.center = (350, 30)
DISPLAYSURF.blit(textSurfaceObj, textRectObj)
pygame.display.update()
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
OSError: unable to read font file 'redline.ttf'
Run Code Online (Sandbox Code Playgroud)
可以使用redline字体吗?