2024-04-29 08:54:20 发布
网友
是否可以区分Python脚本是从web服务器(作为CGI脚本)还是从命令行执行?在
我看到一些只针对PHP和Perl的回复:What is the canonical way to determine commandline vs. http execution of a PHP script?How can I determine if a script was called from the command line or as a cgi script?
Perl answer也适用于Python;请检查^{}environment variable:
import os if 'GATEWAY_INTERFACE' in os.environ: print ('CGI') else: print ('Not CGI. CLI?')
Perl answer也适用于Python;请检查^{} environment variable:
相关问题 更多 >
编程相关推荐