用Python从url上抓取文本之后,想对文本进行逐行的解析,老出错,debug时发现每一行都是一个字母,不是一句完整的话。想不太明白,请大神指教。 fhand 和 line 的 type 都是 str
import urllib.request
fhand = urllib.request.urlopen('http://www.pythonlearn.com/code/mbox.txt').read().decode()
a=0
print (fhand)
for line in fhand:
if a < 5:
    print (type(line) )
    print (line)
    a=a+1
                            
                                    Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
或者: