小编Ale*_*nen的帖子

如何在 os.system 中使用 python 变量?

我正在用python创建小的控制台脚本,我想在其中放置cowsay命令,但是cow说的是变量的名称,字符串所在的位置,而不是变量内的字符串。我怎样才能让牛在变量中说出字符串?

if (command == 'cow'):
    word = raw_input('What does the cow say?  ')
    os.system('cowsay word')
Run Code Online (Sandbox Code Playgroud)

python

5
推荐指数
2
解决办法
2万
查看次数

标签 统计

python ×1