Py学习  »  Python

试图将书分成章节的python错误

Richard Ewing • 5 年前 • 191 次点击  
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from urllib.request import urlopen

#Reading the text of novel from a website
huck_fin_url = 'http://www.gutenberg.org/files/76/76-0.txt'
df = urlopen(huck_fin_url)
huck_fin_text = df.read()
#print(huck_fin_text)
huck_fin_chapters = huck_fin_text.split('CHAPTER ')[1:]

误差

文件“/users/richxxxxx/documents/readbooks.py”,第19行,in huck_fin_chapters=huck_fin_text.split('章')[1:]

typeerror:需要一个bytes-like对象,而不是'str'

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/40218
 
191 次点击  
文章 [ 2 ]  |  最新文章 5 年前