我在使用shutil库时遇到copyfile问题。每次我将文件从一个地方复制到另一个地方时,都使用不同的文件名。这就是为什么我把filename的变量名设为“name1”。有人能帮忙吗?谢谢!
我使用的代码如下:
import os
from shutil import copyfile
path1 = '/home/smc/sw_files'
path11 = '/data/smc'
name1 = data
copyfile('path1 + '/' + name1', 'path11 + '/' + name1')
这就是我得到的错误:
Traceback (most recent call last):
File "python_gdrive_query.py", line 94, in <module>
copyfile('path1 + '/' + name1', 'path11 + '/' + name1')
TypeError: unsupported operand type(s) for /: 'str' and 'str'