- 30
- 0
searchValue = input('search:')
url = url + searchValue
req = request.Request(url)
page = request.urlopen(req)
bsObj = BeautifulSoup(page.read(), "lxml")
print(bsObj)
这是错误
UnicodeEncodeError: 'ascii' codec can't encode characters in position 14-15: ordinal not in range(128)
刚刚在写这个,google了下并没有明确的答案
- 共 0 条
- 全部回答
-
换我堕落ミ 普通会员 1楼
The error message "ascii" codec can't encode characters in position: indicates that Python is unable to correctly decode a character that is not a valid ASCII character. The error message typically occurs when you are trying to encode a string that contains characters outside the ASCII range (0-127), or when you are working with text that has been encoded in a different character encoding format than ASCII.
Here are a few common reasons why you might encounter this error:
-
Encoded text not in ASCII format: If you are encoding text in a format that does not conform to ASCII, such as Unicode, you may encounter this error. Unicode is a global character encoding standard that extends ASCII to include additional characters beyond the basic 128 characters. If you are working with a text that uses a non-ASCII encoding, such as UTF-8 or UTF-16, you need to ensure that the text you are encoding is encoded in ASCII format or has a compatible encoding that supports Unicode characters.
-
Unicode characters outside the ASCII range: Some Unicode characters, such as non-ASCII characters like accented letters or symbols, may not be included in the ASCII range. These characters are represented using Unicode code points outside the range of 0-127, and the ASCII codec does not have a built-in mapping for these characters. To encode a Unicode character, you need to use a character encoding that supports Unicode characters and convert it to an ASCII character first.
-
Incorrect encoding of Unicode text: If you are working with text that has been encoded in a different character encoding format than ASCII, such as UTF-8, you need to ensure that you are using the correct encoding when encoding the text. UTF-8 is a widely supported character encoding format that uses UTF-16 surrogate pairs to represent Unicode characters. If you are using a different character encoding, such as ASCII or ISO-8859-1, you need to ensure that the text you are encoding has been encoded in the correct format and that you have a mapping between the ASCII characters and the corresponding UTF-8 characters.
Here's an example code snippet that demonstrates how to encode a Unicode character in ASCII using Python 3:
```python import unicodedata
Unicode character to encode
unicode_char = "
-
- 扫一扫访问手机版
回答动态

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器更新之后。服务器里面有部分玩家要重新创建角色是怎么回事啊?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题函数计算不同地域的是不能用内网吧?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题ARMS可以创建多个应用嘛?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题在ARMS如何申请加入公测呀?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题前端小程序接入这个arms具体是如何接入监控的,这个init方法在哪里进行添加?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器刚到期,是不是就不能再导出存档了呢?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器的游戏版本不兼容 尝试更新怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器服务器升级以后 就链接不上了,怎么办?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器转移以后服务器进不去了,怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器修改参数后游戏进入不了,是什么情况?预计能赚取 0积分收益
- 回到顶部
- 回到顶部
