我刚刚开始使用Python作为一种学习经验。我知道编程的基本逻辑。我在python中有一个函数,每次执行程序时都在运行,即使它不应该运行。我在函数的开头使用了if语句,但是我不知道为什么这个if语句不起作用。我有另一个类似的功能,工作正常。我错过了一些简单的东西吗?你知道吗
这是一个不起作用的函数。。。你知道吗
def check_artist_art():
if os.path.exists("/tmp/artistinfo") and open("/tmp/artistinfo").read() != title:
#if artist == "":
if os.path.exists(home + "/.artist"):
os.remove(home + "/.artist")
if os.path.exists("/tmp/artistinfo"):
os.remove("/tmp/artistinfo")
print artist
return False
else:
os.path.exists("/tmp/artistinfo") and open("/tmp/artistinfo").read() == artist
return False
return True
这就是正常工作的类似功能。。你知道吗
def check_album():
if os.path.exists("/tmp/albuminfo") and open("/tmp/albuminfo").read() != album:
if os.path.exists(home + "/.album"):
os.remove(home + "/.album")
if os.path.exists("/tmp/albuminfo"):
os.remove("/tmp/albuminfo")
return False
elif os.path.exists("/tmp/trackinfo") and open("/tmp/trackinfo").read() == artist + album:
return False
return True
非常感谢您的帮助。你知道吗
你希望这能做什么?你知道吗
首先,你说“不工作”是什么意思? 第二个-艺术家、专辑和标题变量在哪里指定? 第三,代码如下:
需要更改为:
相关问题 更多 >
编程相关推荐