0

Basically, os.system() can execute shall commands, such as:

os.system("echo $A")

It will work well and output value environment variable A.

But this seems to not work:

os.system("A=b echo $A")

It won't output "b" as expected.

How Python can execute this type of command command?

TieDad
  • 9,143
  • 5
  • 32
  • 58

1 Answers1

0

It won't output "b" as expected.

The expansion $A to empty string is done by the shell earlier, before running echo.

Try this:

os.system("A=b; echo $A")
ramsay
  • 3,197
  • 2
  • 14
  • 13