2024-04-19 03:55:01 发布
网友
这是密码
import os while True: print "Upisite ime datoteke koju zelite izbrisati" izbrisi = os.remove(raw_input(""))
因此,我运行这个程序试图删除文件,但该文件不存在,所以它只是关闭程序,即使它在while循环(当文件确实存在循环continiues)。 我试着用if语句,但没能成功。你知道吗
你可以试试:
import os while True: print "Upisite ime datoteke koju zelite izbrisati" try: fname = raw_input("") izbrisi = os.remove(fname) except OSError as err: print "failed to remove %s" % fname pass #ignore the exception
你可以试试:
相关问题 更多 >
编程相关推荐