日誌2020-05-31 11:05
urlretrieve作者:Yotsuba
import sys from urllib.request import urlretrieve def progress(block_num, block_size, total_size): # block_num : A count of blocks transferred so far # block_size : A block size in bytes # total_size : The total size of the file sys.stdout.write('\rDownloading %s %.1f%%' % (filename, float(block_num * block_size) / float(total_size) * 100.0)) sys.stdout.flush() url = 'https://www.python.org/ftp/python/3.8.3/Python-3.8.3.tgz' filename = 'Python-3.8.3.tgz' urlretrieve(url, filename, progress) print() |
2020-06-09 20:25Yotsuba:當然可以
無論你是用 Python 原生的 open 或是 urlretrieve,路徑和檔名都是寫在一起
比如說這樣的格式 -> C:\example\file.jpg