gpt4 book ai didi

python - IsADirectoryError : [Errno 21] Is a directory: '/home/cali/Dropbox/'

转载 作者:行者123 更新时间:2023-11-28 22:28:35 28 4
gpt4 key购买 nike

我有一个功能,我试图将 XML 文档复制到我的 Dropbox 文件夹,但我得到:

/usr/bin/python3.5 /home/cali/PycharmProjects/Vocabulary/Vocabulary.py
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python3.5/tkinter/__init__.py", line 1553, in __call__
return self.func(*args)
File "/home/cali/PycharmProjects/Vocabulary/Vocabulary.py", line 232, in add_item
self.sync()
File "/home/cali/PycharmProjects/Vocabulary/Vocabulary.py", line 287, in sync
copyfile(vocabulary_path, destination_path)
File "/usr/lib/python3.5/shutil.py", line 115, in copyfile
with open(dst, 'wb') as fdst:
IsADirectoryError: [Errno 21] Is a directory: '/home/cali/Dropbox/'

Process finished with exit code 0

函数如下:

def sync(self):

path = os.path.expanduser('~/Desktop')
vocabulary_path = os.path.join(path, 'Vocabulary', 'Words.xml')
destination_path = os.path.expanduser('~/Dropbox/')

copyfile(vocabulary_path, destination_path)

我该如何解决这个问题?

最佳答案

也许通过将文件复制到另一个文件,而不是目录。

...
destination_path = os.path.expanduser('~/Dropbox/Words.xml')
...

关于python - IsADirectoryError : [Errno 21] Is a directory: '/home/cali/Dropbox/' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43505121/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com