社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

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

Richard Ewing • 5 年前 • 197 次点击  
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
 
197 次点击  
文章 [ 2 ]  |  最新文章 5 年前