2015-12-11 32 views
0

高清CreateDropboxFolder(路徑,文件夾名):Dropbox v2 python api的createfolderarg()函數的格式有什麼問題?

##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 

每一部分的工作。除了上述功能。我嘗試過很多方式來格式化目錄字符串,但它不起作用。經過兩個晚上的挫折之後,我正要把我的頭髮拉出來。 我一直在傳遞Path ='/ Projects /',這是我的保管箱文件夾和FolderName ='test'的根目錄中的一個現有目錄。

+0

「不起作用」?怎麼了?更加詳細一些。 – kindall

回答

0

CreateFolderArg正如其名稱所暗示的那樣,它與您將要傳遞以創建文件夾的參數相對應。你正在創建該類的一個實例,但沒有對它做任何事情。

我想你可能在尋找dbx.files_create_folder(TempDir)

+0

謝謝!我需要停止編碼深夜哈哈。多麼愚蠢的錯誤。 – ChrisB