无法在vi中显示多行文本

2024-10-02 18:26:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在做一个python项目,我需要在屏幕上打印规则。我使用的是simplegui模块,这里是我所拥有的。你知道吗

text = """You will be given a number
    and a number of operations. The number
    on the top is the answer to the problem.
    You must fill the blanks with numbers that
    make the answer. Hit enter when you are 
    done, hit delete to go back."""
canvas.draw_text(text, (150, 250), 30, 'white')

它给了我一个错误:

ValueError: text may not contain non-printing characters

如何修复此错误?你知道吗


Tags: 模块theto项目textansweryounumber
1条回答
网友
1楼 · 发布于 2024-10-02 18:26:19

draw_text()函数不能绘制多行。你必须一行一行地画。你知道吗

但是…我写了一个函数来画多行: ^{} 必须导入^{}模块,因为它不是CodeSkulptor的函数。你知道吗

try:
    import simplegui

    import user40_AeChfAkzlcqs3wG as simplegui_lib_draw
except ImportError:
    import SimpleGUICS2Pygame.simpleguics2pygame as simplegui

    import SimpleGUICS2Pygame.simplegui_lib as simplegui_lib_draw

def draw(canvas):
    …
    draw_text_multi(canvas,
                    """line 1
line 2
line 3""", (x, y), size, 'white', 'serif')
    …

另请阅读SimpleGUICS2Pygame文档中的Tips部分。你知道吗

相关问题 更多 >