【问题标题】:How to pass the arguments in the console command in python? [duplicate]如何在python的控制台命令中传递参数? [复制]
【发布时间】:2018-03-02 11:42:42
【问题描述】:

我正在尝试在控制台命令中传递参数。我正在使用 django 框架。我正在尝试类似下面的命令。例如。

django框架中的调试配置:

python manage.py command_name args

This is how i configured but getting error

【问题讨论】:

  • 这个链接可以帮助你:1 --- 2 --- 3

标签: python


【解决方案1】:

您可以尝试使用sys 库,类似这样:

import sys
print "This is the name of the script: ", sys.argv[0]
print "Number of arguments: ", len(sys.argv)
print "The arguments are: " , str(sys.argv)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-02-08
    • 2021-05-12
    • 1970-01-01
    • 2016-12-17
    • 2013-06-19
    • 1970-01-01
    • 1970-01-01
    • 2015-04-29
    相关资源
    最近更新 更多