对于下面的构造还有什么更pythonic的方式呢?
如果它是 C,我可以只使用 !
但它在 Python 中等同于什么?
file_path = # something
if os.path.exists(file_path):
pass
else:
file_path = # make new path
最佳答案
file_path = # something
if not os.path.exists(file_path):
file_path = #make new path
关于Python 相当于 !运算符(operator),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6937473/