下面的命令在python中有效吗?
下面的命令在python中有效吗下面的命令在python中有效吗?,python,Python,下面的命令在python中有效吗 if(os.path.isfile("file path") && os.path.isfile("another file path") ) 将是您问题的正确语法 这是有效的Python吗 否,&&不是有效语法,您需要为下一个代码块使用冒号。然而,这将是更好的风格: if os.path.isfile("file path") and os.path.isfile("another file path"): # ... 你为什么不
if(os.path.isfile("file path") && os.path.isfile("another file path") )
将是您问题的正确语法
这是有效的Python吗
否,&&不是有效语法,您需要为下一个代码块使用冒号。然而,这将是更好的风格:
if os.path.isfile("file path") and os.path.isfile("another file path"):
# ...
你为什么不打开IDLE并尝试一下呢?你是说and,not&&。no,&&无效语法这个问题似乎离题了,因为这是一个对其他人都没有用处的是/否问题。@Sunny:你为什么不先问这个问题?但是,在这种情况下,我建议您阅读一篇教程,了解基本知识:
if(os.path.isfile("file path") && os.path.isfile("another file path") )
if os.path.isfile("file path") and os.path.isfile("another file path"):
# ...