dropbox v2 python api的createfolderarg()函数的格式有什么问题?
def CreateDropboxFolder(路径,FolderName): 每个部分都工作。除上述功能外。我尝试了很多方法格式化目录字符串,但都不起作用。在经历了两个晚上的挫折之后,我准备把头发拔出来。dropbox v2 python api的createfolderarg()函数的格式有什么问题?,python,api,dropbox,Python,Api,Dropbox,def CreateDropboxFolder(路径,FolderName): 每个部分都工作。除上述功能外。我尝试了很多方法格式化目录字符串,但都不起作用。在经历了两个晚上的挫折之后,我准备把头发拔出来。 我一直在传递Path='/Projects/',这是我的dropbox文件夹根目录中的一个现有目录,FolderName='test'。CreateFolderArg顾名思义,是一个与创建文件夹时要传递的参数相对应的类。您正在创建该类的实例,但没有对其进行任何操作 我想您可能正在寻找dbx.
我一直在传递Path='/Projects/',这是我的dropbox文件夹根目录中的一个现有目录,FolderName='test'。
CreateFolderArg
顾名思义,是一个与创建文件夹时要传递的参数相对应的类。您正在创建该类的实例,但没有对其进行任何操作
我想您可能正在寻找
dbx.files\u create\u folder(TempDir)
“不工作”?会发生什么?具体点,谢谢!我需要停止深夜编码哈哈。多么愚蠢的错误啊。
##Connect to Dropbox with Supplied Access token
print('Connecting to Dropbox...')
dbx = dropbox.Dropbox('')
print('Connected to Dropbox')
##Reset Variables
DirExists=False
##Set Directory
TempDir=Path+FolderName
print('Started Creating New Directory: ' + TempDir + ' ...')
##Check if Location exists
print ('Searching for Existing Directory in '+ Path)
for entry in dbx.files_list_folder(path=os.path.dirname(Path)).entries:
print (entry.name)
if(entry.name==FolderName):
DirExists=True
break
##If Folder Directory exists Skip Create Directory
if DirExists==True:
print ('Folder Already Exists')
##If Folder Directory exists Create Directory
else:
##Create Client Directory
print('Creating New Directory: ' + TempDir)
dropbox.files.CreateFolderArg(os.path.dirname(TempDir))
print('Created New Directory: ' + TempDir)
return TempDir