猿问
python FTP 如何检查路径
如何实现检查FTP上的目录,如果目录不存在 则建立
使用的了一下 mkd命令,可以实现建立, 但是无法判断目录是否存在
大话西游666
浏览 1919
回答 3
3回答
蛊毒传说
........ SERVER_PATH = "xxxxxxxxxxx" try:     ftp.cwd(SERVER_PATH) except:         try:         ftp.mkd(SERVER_PATH)         ftp.cwd(SERVER_PATH)      except:         meg = 'You have no authority to make directory: %s'%SERVER_PATH                 print meg .....
0
0
0
蝴蝶不菲
读父目录的文件列表看你想要的目录是否存在啊!
0
0
0
慕仙森
刚试验出来的,送你        try:            ftp.cwd(self.remotedir)        except ftplib.error_perm:            try:                ftp.mkd(self.remotedir)            except ftplib.error_perm:                print "Change directory failed!"
0
0
0
随时随地看视频
慕课网APP
我要回答