1。
myCoolVariable="some_string"
os.system("echo myCoolVariable")
2.
>>> os.system('echo "asdg"') asdg 0 >>> os.system("echo 'asdgwere'") asdgwere 03.$ python >>>hamburger="potato" >>>import os >>>os.system("echo 'hamburger'")potato 04.hamburger=os.system('echo $MY_SHELL_VAR | sed "s/longsed/replacement/g"')5.>>> string="python is cool" >>> cmd="echo "+string >>> os.system(cmd) python is cool 0 >>>6.bash$ python Python 2.4.3 (#1, May 18 2006, 07:40:45) [GCC 3.3.3 (cygwin special)] on cygwin Type "help", "copyright", "credits" or "license" for more information. >>> from os import system >>> food = 'spam' >>> system('echo %(food)s' % locals()) spam 0 >>>