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')
上一篇:在某些情况下明明添加了引用,为何VS还报错"XXX"不存在类型或命名空间(是否缺少程序集引用)


下一篇:[Luogu]P3338 [ZJOI2014]力(FFT)