
請建議我的語法有什麼問題(我在 bash 腳本中使用它)
export CALC=3.4373
python -c 'print CALC > 2.2'
Traceback (most recent call last):
File "<string>", line 1, in ?
NameError: name 'CALC' is not defined
應該得到 True
答案1
不要使用''
.它不解析 bash 變數。
你想要的是:python -c "print ${CALC} > 2.2"