您可以使用urllib.parse.quote()对URL的路径部分进行编码。
#!/usr/bin/env python3
from urllib.parse import quote
from urllib.request import urlopen
url = 'http://zh.wikipedia.org/wiki/' + quote("毛泽东")
content = urlopen(url).read()
如何在python3中处理URL中的unicode字符串?
您可以使用urllib.parse.quote()对URL的路径部分进行编码。
#!/usr/bin/env python3
from urllib.parse import quote
from urllib.request import urlopen
url = 'http://zh.wikipedia.org/wiki/' + quote("毛泽东")
content = urlopen(url).read()