2.2使用urllib的简单传输
使用urllib传输文件
from urllib.request import urlopen filename = 'new_1.py' password = 'password' #如果设置密码 #remoteaddr = 'ftp://lutz:%s@192.168.191.1/%s;type=i'%(password,filename) #如果没有设置密码 remoteaddr = 'ftp://192.168.191.1/%s;type=i'%(filename) print('Downloading...',remoteaddr) remotefile = urlopen(remoteaddr) localfile = open(filename,'wb') localfile.write(remotefile.read()) localfile.close() remotefile.close() print('Finished')