下面的命令在python中有效吗?

2024-04-19 02:17:53 发布

您现在位置:Python中文网/ 问答频道 /正文

下面的命令在python中有效吗?你知道吗

if(os.path.isfile("file path") && os.path.isfile("another file path") ) 

Tags: path命令ifosanotherfileisfile
2条回答
if os.path.isfile("file path") and os.path.isfile("another file path"):
    do something

是你问题的正确语法。你知道吗

Is this valid Python?:

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"):
    # ...

相关问题 更多 >