Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
下面的命令在python中有效吗?_Python - Fatal编程技术网

下面的命令在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"): # ... 你为什么不

下面的命令在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"):
    # ...

你为什么不打开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"):
    # ...