开发者

In Python, what is the difference between the 'urllib library' and the 'socket library'?

I'm开发者_如何转开发 learning network programming basics, and there is a question I don't know how to answer in my assignment.

How is 'urllib library' different from 'socket library' in Python? How can I explain it clearly?


urllib is much higher level.

socket provides low-level access to many different kinds of sockets, which you can use to communicate over any port and protocol. For example, you could use it for email, SSH, remote desktop, etc. You can also use it for to listen on a port (for a server). Almost all Python networking libraries, including urllib, use socket somehow.

urllib is specialized to particular uses of sockets, namely the client side of the HTTP (and optionally TLS) and FTP protocols, typically (but not always) using ports 80, 443, or 21.


In my basic mindset, urllib require you less code line and more consistent to attach to the server. In fact, socket may take you much more time to access the internet and require you more code to process through your code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜