Python 和 BeautifulSoup 编码错误

Python and BeautifulSoup error in encoding

我收到错误:

File "C:\Python34\lib\encodings\cp1252.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\u0106' in position 73: character maps to

这是我的代码:

import requests
from bs4 import BeautifulSoup

url = 'http://www.privredni-imenik.com/firma/68225-a_expo'
r = requests.get(url)

soup = BeautifulSoup(r.content, "html.parser")

g_data = soup.find_all("div", {"class":"podaci"})
print(g_data)

我如何在 utf-8 中编码数据。 我尝试过其他主题的解决方案,但 none 对我有用。

import requests
from bs4 import BeautifulSoup

url = 'http://www.privredni-imenik.com/firma/68225-a_expo'
r = requests.get(url)

soup = BeautifulSoup(r.content, "html.parser")

g_data = soup.find_all("div", {"class":"podaci"})
for i in g_data:
    some = i.text.encode('utf-8', 'replace')
    print (some)

它在接收数据时有效,但带有奇怪的字符。那是另一个主题的问题:)