如何在Python中获取原始命令行?带有空格,制表符等 [英] How do I get the ORIGINAL command line in Python? with spaces, tabs, etc

查看:66
本文介绍了如何在Python中获取原始命令行?带有空格,制表符等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

输入的完整命令行


sys.argv 已经是一个已解析的数组,丢失了双引号,双精度空格甚至制表符(当然,这全都取决于OS / shell)。 / p>

如何在解析之前访问原始字符串?

解决方案



长:在Unix命令行上,调用程序已对它进行了解析,而到python启动时,您已经对命令行进行了解析。

>

PS。在Windows上有可能,但我想您正在寻找一般的答复。


Possible Duplicate:
Full command line as it was typed

sys.argv is already a parsed array, losing double quotes, double spaces and maybe even tab characters (it all depends on the OS/shell, of course).

How can I access the original string before parsing?

解决方案

Shortly, you don't.

Long: on Unix command line is parsed by the calling program and by the time python starts you already have the command line parsed.

PS. On Windows it is possible, but I suppose you are looking for a general response.

这篇关于如何在Python中获取原始命令行?带有空格,制表符等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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