这个测试输出是什么意思 python

what's this test output mean python

我正在从事一个开源项目。该项目的目标是创建俄罗斯方块游戏。构建游戏时涉及一系列测试。第一个测试确保计算机可以找到您的代码。基本上只是将文件保存在正确的位置。我每次都通过它。然后第二个测试是打印游戏板。这是通过第二个测试的 p 命令代码:

   def test2():
        while True:
         qp = raw_input('')
         if qp=='p':

          for i in range(0,22):
             for j in range(0,10):
               print'.',
             print''
        else:
           return exit()

    test2()

它打印输出,一个点矩阵。类似于俄罗斯方块布局的 10 x 22 点输出。然后代码转到第 3 步,即使用 'g command' 将一些内部表示填充到矩阵中。它还说 "The input format should be identical to the output produced by the 'p' command"。当它说输入格式时,它是指代码吗?我尝试了多种代码,最终我将两个参数组合成一个 while 语句。特别是这个 while 语句:

  def test3():
        while True:
            qp = raw_input('')
            if qp == 'p' or qp == 'g':

                for i in range(0, 22):
                    for j in range(0, 10):
                        print'.',
                    print''

            else:
                return exit()

    test3()

显然,当我 运行 我的 PyCharm 调试器中的代码时,无论我输入 'p' 还是 'g',它都会吐出一个空白的 10x22 矩阵。我猜这是意料之中的,因为他们使用相同的 while 循环。但是当我在 mac 的终端中 运行 它时,它不会产生空白矩阵。它产生了预期输出(可以在底部的 link 上看到)的可怕间隔和失真输出 (https://imgur.com/a/ryNsN)。所以我知道我的代码是错误的,但我认为这是因为我在等待测试 3 的结果时误解了提示。程序说的是什么意思:

 The 'g' command instructs learntris to read 22 lines
of text from the standard input stream, and use the
characters on these lines to populate some internal
representation of the matrix.

The letter 'g' is a mnemonic for the word 'given', as
in: "given the following matrix...."

The input format should be identical to the output
produced by the 'p' command.

The letters used in the representation correspond to
the set of colors used for blocks in the game:

. = empty (black)     b = blue         c = cyan
g = green             m = magenta      o = orange
r = red               y = yellow

您可以在此处详细了解测试 3 的预期输出:https://github.com/LearnProgramming/learntris/blob/master/testplan.org#establish-a-way-to-set-the-entire-matrix-g

那么谁能帮我弄清楚 "the input format should be identical to the output produced by the 'p' command" 是什么意思,这样我就可以解决这个代码并进入下一步?

非常简单,p命令的输出成为g命令的输入;这是一个简单的数据流。不要合并这两个命令的代码。先编码p命令,目测输出。然后,编写 g 命令的代码——第一步是让它读取 p 命令生成的文件。