如何让Python将文件复制到桌面

0 投票
1 回答
2365 浏览
提问于 2025-04-18 08:46

我该怎么用Python把一个jpeg图片复制到桌面上呢?

import shutil
src = ('1.3.jpg')
dst = ('tEST/nicholas')
count = 1
while count < 10000000000:
    shutil.copyfile(src, dst + str(count) + ".jpg")
    count += 1

这是我现在写的代码,但我想把目标文件夹改成桌面,因为我用的是Windows 7。

1 个回答

2

只需要定义你桌面的绝对地址。

dst = 'C:\\Users\\[name of your account]\\myfile.txt'

撰写回答