เพราะบทความจะพาผู้อ่านเขียนโปรแกรมโหลดไฟล์แบบกำหนดลิงค์ไฟล์ที่แน่นอนครับ
ใน Python เราต้องใช้โมดูล urllib
โค้ดโปรแกรม
import urllib.request, urllib.parse, urllib.error
url = '' #ลิงค์ไฟล์ตัวอย่างเช่น http://th.wordpress.org/wordpress-3.9.1-th.zip
print("downloading with urllib")
urllib.request.urlretrieve(url,"wordpress.zip")
print("downloading with urllib2")
f = urllib.request.urlopen(url)
data = f.read()
การนำไปพัฒนาต่อผู้อ่านสามารถศึกษาโมดูล urllib เพิ่มเติมและเขียนโปรแกรมโหลดไฟล์โดยใช้ Python โหลดไฟล์ทีละไฟล์ตามรายการที่กำหนดใน Text ไฟล์,แบบ GUI,โหลดได้หลายรายการพร้อมกัน
ขอบคุณครับ

0 ความคิดเห็น:
แสดงความคิดเห็น
แสดงความคิดเห็นได้ครับ :)