Python 命令提示符中的权限被拒绝,但仍在生成输出
我在做一个开源项目。具体地说 在Python 命令提示符中的权限被拒绝,但仍在生成输出,python,python-2.7,shell,command-line,Python,Python 2.7,Shell,Command Line,我在做一个开源项目。具体地说 在readme.md中,它基本上说为了开始,制作一个名为learntris.py的空程序。第一步是指示命令行定位learntris.py文件 对其进行了更深入的解释 我使用了成功的语法来定位文件并生成输出,但我认为这就是问题所在。根据的预期输出如下所示: Running test 1: io.q q : quit ---- sending commands ---- q ---- awaiting results ---- Test 1 passed Runni
readme.md
中,它基本上说为了开始,制作一个名为learntris.py
的空程序。第一步是指示命令行定位learntris.py
文件
对其进行了更深入的解释
我使用了成功的语法来定位文件并生成输出,但我认为这就是问题所在。根据的预期输出如下所示:
Running test 1: io.q
q : quit
---- sending commands ----
q
---- awaiting results ----
Test 1 passed
Running test 2: io.p
p : print
---- sending commands ----
p
q
---- awaiting results ----
: The 'p' command instructs learntris to print the state
: of the Matrix, the rectangular array of cells in which
: blocks can appear.
:
: The Matrix is 10 cells wide and 22 cells deep, although
: the top two rows are used only for spawning new Tetraminos.
:
: At the start of the game, the Matrix should be empty.
: The 'p' command should indicate empty cells with the
: '.' character.
:
: Cells should be separated by spaces.
:
: Lines should be separated by the standard end of line
: sequence on your operating system (python's "\n").
然后是输出的其余部分。当我运行learntris.py
文件时,我得到了完全相同的输出,但有一个关键点不同。它说在打印出p命令…
部分之前,权限被拒绝
Running test 1: io.q
q : quit
---- sending commands ----
q
---- awaiting results ----
/bin/sh: ./learntris.py: Permission denied
Test 1 passed
Running test 2: io.p
p : print
---- sending commands ----
p
q
---- awaiting results ----
/bin/sh: ./learntris.py: Permission denied
: The 'p' command instructs learntris to print the state
: of the matrix, the rectangular array of cells in which
: blocks can appear.
:
: The matrix is 10 cells wide and 22 cells deep, although
: the top two rows are used only for spawning new Tetraminos.
:
: At the start of the game, the matrix should be empty.
: The 'p' command should indicate empty cells with the
: '.' character.
:
: Cells should be separated by spaces.
:
: Lines should be separated by the standard end of line
: sequence on your operating system (python's "\n").
那么为什么许可被拒绝,这对我的输出有什么影响呢 您运行测试脚本的方式
testris.py
(您没有在问题中透露这一点,因此我不确定说明是否不完整,或者您是否没有完全遵循说明)要求您在测试真正成功运行您的程序之前执行chmod+x./learntris.py
您只需执行一次,只要不从磁盘中删除文件,执行权限就会保留在磁盘上,即使您编辑或以其他方式修改它。您可以执行
ls-la
并发布位于最左侧的tetris.py
文件的权限吗,我的假设是你需要提供这些文件permissions@aws_apprentice是的,我做了,它说-rw-r--r--您没有执行脚本的权限。Try command:$chmod+x tetris.py
允许每个人运行脚本(x-execute、w-write、r-read)。@AnnaRudzińska我尝试运行$chmod+x testris.py,但$x使它出错。当我输入chmod+xtestris.py时,它只是输出了另一个命令行。然后,我尝试运行learntris.py,在第一次测试和第二次测试后出现权限拒绝错误。错误消息是因为您没有chmod+x./learntris.py
只是为了完整性,这是基于U*x的系统特有的,与Windows无关。