【发布时间】:2019-05-17 22:08:05
【问题描述】:
我有以下代码来删除我的本地文件夹之一中的文件。我从其他用户帖子中获取了代码。
但是,它似乎对我不起作用。下面是我的代码
蟒蛇
import os
def deletefile():
filePath = "/Users/Jose/Documents"
os.remove(os.path.join(filePath, "tweets.db"))
print("Ok while deleting file ", filePath)
deletefile()
以下是我遇到的错误。我究竟做错了什么?为什么 Python 将“\u200e\u2068\u200e\u2068/”放在我的路径前面?
Traceback (most recent call last):
File "tests.py", line 17, in <module>
deletefile()
File "tests.py", line 11, in deletefile
os.remove(os.path.join(filePath, "tweets.db"))
FileNotFoundError: [Errno 2] No such file or directory: '\u200e\u2068\u200e\u2068/Users/Jose/Documents/tweets.db'
【问题讨论】: