键入时的完整命令行 [英] Full command line as it was typed

查看:23
本文介绍了键入时的完整命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在输入时获取完整的命令行.

I want to get the full command line as it was typed.

这个:

" ".join(sys.argv[:])

在这里不起作用(删除双引号).此外,我不希望重新加入已解析和拆分的内容.

doesn't work here (deletes double quotes). Also I prefer not to rejoin something that was parsed and split.

有什么想法吗?

推荐答案

你来晚了.当键入的命令进入 Python 时,您的 shell 已经发挥了它的魔力.例如,引用被消耗(正如您所注意到的),变量被插入等.

You're too late. By the time that the typed command gets to Python your shell has already worked its magic. For example, quotes get consumed (as you've noticed), variables get interpolated, etc.

这篇关于键入时的完整命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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