som*_*ing 0 linux shell bash programming python
我有时需要pass
在我的 bash 脚本中使用 Python 之类的命令。
喜欢:
if grep something
then
pass
else
code
fi
Run Code Online (Sandbox Code Playgroud)
在 Python 中,你有:
>>> for element in a:
... if not element:
... pass
... print element
Run Code Online (Sandbox Code Playgroud)
题:
我总是使用,continue
但它给出了一个错误,它应该只在for
,while
或until
循环中使用。
在这种情况下你会怎么做?
Ste*_*itt 10
您的标题由bash 脚本中的 A do nothing line完全回答::
或者true
实际上等效于pass
.
但是在这些情况下,我会改变条件:
if ! grep something
then
code
fi
Run Code Online (Sandbox Code Playgroud)
和
>>> for element in a:
... if element:
... print element
Run Code Online (Sandbox Code Playgroud)