如何从urllib中读取lines()

如何从urllib中读取lines(),第1张

如何从urllib中读取lines()

urlopen()
返回一个行为类似于文件的对象,并支持
.readlines()

response = urllib.request.urlopen(someAddress)lines = response.readlines():

它还支持迭代:

response = urllib.request.urlopen(someAddress)for line in response:

您已经调用

.read()
了响应对象;您也可以致电
str.splitlines()

lines = data.splitlines(True)

这里

True
告诉
str.splitlines()
保留行尾。



欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/zaji/5664289.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存