在Python中,“urllib库”和“urllib库”有什么区别?和“套接字库”?

发布于 2024-10-02 14:24:09 字数 98 浏览 5 评论 0原文

我正在学习网络编程基础知识,我的作业中有一个问题我不知道如何回答。

Python 中的“urllib 库”与“socket 库”有何不同? 我怎样才能解释清楚呢?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

巴黎盛开的樱花 2024-10-09 14:24:09

urllib 级别要高得多。

socket 提供对许多不同类型套接字的低级访问,您可以使用它通过任何端口和协议进行通信。例如,您可以将其用于电子邮件、SSH、远程桌面等。您还可以将其用于侦听端口(用于服务器)。几乎所有 Python 网络库(包括 urllib)都以某种方式使用套接字。

urllib 专门用于套接字的特定用途,即 HTTP(以及可选的 TLS)和 FTP 协议的客户端,通常(但不总是)使用端口 80、443 或 21。

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.

自找没趣 2024-10-09 14:24:09

在我的基本思维中,urllib 需要更少的代码行并且更一致地附加到服务器。事实上,socket 可能会花费您更多的时间来访问互联网,并且需要您更多的代码来处理您的代码。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文