Call Python script from bash with argument

前端 未结 8 877
长发绾君心
长发绾君心 2020-11-29 16:37

I know that I can run a python script from my bash script using the following:

python python_script.py

But what about if I wanted to pass a

8条回答
  •  天涯浪人
    2020-11-29 17:23

    Use

    python python_script.py filename
    

    and in your Python script

    import sys
    print sys.argv[1]
    

提交回复
热议问题