linux - 打开子进程 python 时出错

标签 linux python-2.7

我在尝试打开 txt 时遇到此错误。文件。请告诉如何修复它。

code: subprocess.Popen("/home/yash/Documents/ct.txt")
      time.sleep(1)
error: 
     Traceback (most recent call last):
     File "/home/yash/Documents/final_downloader22.py", line 5, in <module>
     subprocess.Popen("/home/yash/Documents/ct.txt")
     File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
     errread, errwrite)
     File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
     raise child_exception
     OSError: [Errno 13] Permission denied

最佳答案

文本文件通常不可执行。这里的“开放”是什么意思?

  1. 这可能意味着“打开它以便我可以在程序中使用它”。

    这适用于 file_object = open('/home/yash/Documents/ct.txt', 'r') 然后使用那个 file_object

  2. 这也可能意味着“让文件类型的关联应用程序打开文件,以便用户可以编辑它”。

    在这种情况下,您必须找出关联的应用程序是什么。如何执行此操作取决于您使用的操作系统以及窗口管理器/桌面环境。不是几句话就能回答的。

关于linux - 打开子进程 python 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13331269/

相关文章:

linux - 如何在 Shell 脚本中生成每个主机的 UUID?

python-2.7 - jinja2 忽略最后一行?

python - 反斜杠 b 在 Python 中有什么作用?

linux - 根据版本对文件进行排序

linux - 如何在 Linux 上读取 RTS/CTS 引脚的值?

python-2.7 - Tensorflow while 循环 : dealing with lists

python - 打印循环的 PyQt4 Gui

python - Ubuntu - 找不到适用于 python2 的 PySide 模块,但适用于 python3

linux - 在Ubuntu Server 16.04的fstab中自动挂载VirtualBox共享文件夹

android - 出现错误 : inconsistent operand constraints in an 'asm' while porting my c++ code from linux to android