How to send Python variable to bash variable?

后端 未结 4 1841
终归单人心
终归单人心 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:39

    you are passing astring you can use value of x like

    sytem('say {0}'.format(x))

    When passing strings you can use string formatting. As you realized you need to get the value of x in the string not the variable x http://docs.python.org/library/string.html#format-examples

提交回复
热议问题