在 bash/shell 编程中,python 中是否有类似或类似的“pass”?

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,whileuntil循环中使用。

在这种情况下你会怎么做?

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)