How to send Python variable to bash variable?

后端 未结 4 1792
终归单人心
终归单人心 2021-01-28 06:45

I am trying to use Python to select a variable from a list, then speak it outloud using the bash command. Right now I have something like this

foo = [\"a\",\"b\"         


        
4条回答
  •  礼貌的吻别
    2021-01-28 07:33

    use string formatting:

    In [9]: x="ls -ld"
    
    In [10]: os.system("{0}".format(x))
    drwxr-xr-x 41 monty monty 4096 2012-10-10 22:46 .
    Out[10]: 0
    

提交回复
热议问题