如何处理“输入行太长”错误信息? [英] What to do with "The input line is too long" error message?

查看:1868
本文介绍了如何处理“输入行太长”错误信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用os.system()来调用另一个程序,它接受输入和输出文件。我使用的命令是〜250个字符,由于长文件夹名称。



当我尝试调用该命令时,我收到一个错误:输入行太长



我猜想有一个 255个字符限制(它使用C系统调用构建,我尝试用 os.chdir()更改目录,以减少这个限制。



<文件夹路径长度,但是当我尝试使用 os.system().. \folder\filename它显然不能处理相对路径名。有没有办法绕过这个限制或让它识别相对路径?

解决方案

你应该使用subprocess模块​​。请参见小文档,了解如何重写os.system调用以使用子过程。


I am trying to use os.system() to call another program that takes an input and an output file. The command I use is ~250 characters due to the long folder names.

When I try to call the command, I'm getting an error: The input line is too long.

I'm guessing there's a 255 character limit (its built using a C system call, but I couldn't find the limitations on that either).

I tried changing the directory with os.chdir() to reduce the folder trail lengths, but when I try using os.system() with "..\folder\filename" it apparently can't handle relative path names. Is there any way to get around this limit or get it to recognize relative paths?

解决方案

You should use the subprocess module instead. See this little doc for how to rewrite os.system calls to use subprocess.

这篇关于如何处理“输入行太长”错误信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆