- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在制作一个小程序,我可以使用它的默认编辑器从计算机的任何部分打开文件。这是我的代码:
from os import *
import subprocess
print("Welcome to my File Finder. Here you can search for a file and open it.")
file_name = str(input("Your file's name:"))
print(subprocess.call(["xdg-open"], file_name))]
但是它没有打开,而是返回了这个错误:
Traceback (most recent call last):
File "Important_tester_projects.py", line 6, in <module>
print(subprocess.call(["xdg-open"], file_name))
File "/usr/lib/python3.6/subprocess.py", line 267, in call
with Popen(*popenargs, **kwargs) as p:
File "/usr/lib/python3.6/subprocess.py", line 609, in __init__
raise TypeError("bufsize must be an integer")
TypeError: bufsize must be an integer
我已经用谷歌搜索了这个错误的解决方案,但我找不到任何似乎可以解决我的问题的方法。如何解决我的错误?
注意:我的 Linux 操作系统使用 XFCE,而不是 Gnome。
最佳答案
相反,使用 subprocess.check_output()
。由于您的命令有多个单词,请使用 shlex 中的 split()
方法解析您的命令库。像这样:
import subprocess
import shlex
cmd=shlex.split('[find][2] root_dir -name file_name')
print subprocess.check_output(cmd)
关于python - 类型错误 : bufsize must be an integer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51529415/
有谁知道 bufsize 的公式是什么以及它在 FFMPEG 中检查的速率? 我似乎找不到任何具体的答案。 是吗: bufsize = 比特率/速率 ? 它应该在计算中使用 maxrate 而不是 b
我试图运行并处理某个 java 程序的标准输出,发现我的 Python 脚本永远在等待。然后我编写了一个新的测试脚本来测试 subprocess 并再次发现运行此脚本时没有看到任何输出: $ cat
我正在制作一个小程序,我可以使用它的默认编辑器从计算机的任何部分打开文件。这是我的代码: from os import * import subprocess print("Welcome to my
对于一项作业,我应该创建两种方法:方法一是 read()和 write()输入文件到一个空的输出文件,一次一个字节(慢慢地)。 另一种方法将改为使用 char buf[BUFSIZ];其中 BUFSI
$ getconf BUFSIZgetconf: Unrecognized variable 'BUFSIZ' 是否有一种标准方法可以从 shell 中确定 BUFSIZ 的值?编写一个简单的 C 程
我有两个小的 python 文件,第一个使用 input 读取一行然后打印另一行 a = input() print('complete') 第二次尝试将其作为子进程运行 import subproc
背景信息 我正在尝试获取用户用户名的字符串,唯一提供的有关该用户的信息是他们的 uid 号码。由于先前调用 fstat,我有 uid(并且 uid 存储在 struct stat). 我需要以线程安全
我正在编写一个小型套接字程序 (GNU libc)。我有一个循环要求用户输入(例如“MSG>”)。当用户按下回车键时,消息被发送(当前发送到本地主机上的服务器)。 无论如何,我想从标准输入读取到字符缓
我正在尝试分析一些调用 readlink 的代码(不是我自己编写的)积极的bufsize ,然后测试结果是否为零。我看不出结果如何为零,我尝试过的所有内容都是-1,实际链接的大小或软链接(soft l
这个问题在这里已经有了答案: bufsize must be an integer error while grepping a message (1 个回答) 关闭 6 年前。 我正在尝试从一个目
我在尝试 grep 查找由日志中的多行组成的消息时遇到以下错误...任何人都可以提供有关如何克服此错误的输入吗? 代码:- print gerrit_commitmsg gerritl
我在 C 编程中遇到了这个问题: 问题:下面的代码片段中用零填充缓冲区的缺陷是什么?如何解决这个问题? char*buf; buf=malloc(BUFSIZ); memset(buf,0,BUFSI
我正在编写一个简单的 Linux USB 字符驱动程序,允许从它创建的设备节点读取一个短字符串。 它工作正常,但我注意到使用 cat 从设备节点读取和使用 Files.readAllBytes 从 J
我们是否使用 lu 和 unsigned long 强制转换,如: printf("%lu\n", (unsigned long)BUFSIZ); /* 512 */ 希望最好的?还是有别的办法? 这
我正在尝试读取从 Python 调用的子进程的输出。为此,我使用 Popen(因为我认为如果使用 subprocess.call 则无法通过管道传输标准输出)。 截至目前,我有两种方法可以做到这一点,
要从 python 中的套接字读取数据,请调用 socket.recv,它具有以下签名: socket.recv(bufsize[, flags]) python docs for socket.re
我正在尝试编写 python 文件,即 python 中的 wxtrac tar 文件。 据我所知,subprocess 是完成此任务的合适工具。 我写了下面的代码: from subprocess
在python中,方法是: socket.recv(bufsize[, flags]) 在C中,方法是: int recv( _In_ SOCKET s, _Out_ char *buf, _In_
我是一名优秀的程序员,十分优秀!