如何处理“输入行太长”错误信息?

编程入门 行业动态 更新时间:2024-10-23 16:23:38
本文介绍了如何处理“输入行太长”错误信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我尝试使用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.

更多推荐

如何处理“输入行太长”错误信息?

本文发布于:2023-07-14 22:04:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1107285.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误信息   太长   如何处理

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!