脚本如何知道是否已使用-i命令行选项调用它? [英] How a script can know if it has been called with the -i command line option?

查看:82
本文介绍了脚本如何知道是否已使用-i命令行选项调用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

主题说明了一切,我希望脚本在

被称为

$ python script.py并且当被称为$ python -i脚本时采取不同的行动的.py。我在sys模块看了



但是我没有看到检索命令行标志的方法,应该在哪里

我看?

TIA,

Michele Simionato

The subject says it all, I would like a script to act differently when
called as
$ python script.py and when called as $ python -i script.py. I looked
at the sys module
but I don''t see a way to retrieve the command line flags, where should
I look?
TIA,

Michele Simionato

推荐答案

python script.py和当被称为
python script.py and when called as


python -i script.py时。我在sys模块看了



但是我没有看到检索命令行标志的方法,应该在哪里

我看?

TIA,

Michele Simionato

python -i script.py. I looked
at the sys module
but I don''t see a way to retrieve the command line flags, where should
I look?
TIA,

Michele Simionato


Michele Simionato schrieb:
Michele Simionato schrieb:

主题说明了一切,我希望脚本在

调用时采取不同的行动
The subject says it all, I would like a script to act differently when
called as


这篇关于脚本如何知道是否已使用-i命令行选项调用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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