You could use urllib.parse.quote() to encode the path section of 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()
More Related Contents:
- What is the best way to remove accents (normalize) in a Python unicode string?
- UnicodeDecodeError: ‘charmap’ codec can’t decode byte X in position Y: character maps to
- How to set sys.stdout encoding in Python 3?
- “Unicode Error “unicodeescape” codec can’t decode bytes… Cannot open text files in Python 3 [duplicate]
- How can I convert surrogate pairs to normal string in Python?
- How to correct TypeError: Unicode-objects must be encoded before hashing?
- Normalizing Unicode
- Facebook JSON badly encoded
- NameError: global name ‘unicode’ is not defined – in Python 3
- Why doesn’t Python recognize my utf-8 encoded source file?
- Python 3 print() function with Farsi/Arabic characters [duplicate]
- How to make unicode string with python3
- Python 3: How to specify stdin encoding
- Identifier normalization: Why is the micro sign converted into the Greek letter mu?
- requests.get returns 403 while the same url works in browser
- How to encode Python 3 string using \u escape code?
- What is internal representation of string in Python 3.x
- Set encoding in Python 3 CGI scripts
- Python 3 chokes on CP-1252/ANSI reading
- How to make print() output UTF-8 in Python 3.0?
- How to annotate function that takes a tuple of variable length? (variadic tuple type annotation)
- Customizing the order of legends in plotly
- Performing len on list of a zip object clears zip [duplicate]
- Run process with realtime output to a Tkinter GUI
- Python3 project remove __pycache__ folders and .pyc files
- What does the slice() function do in Python?
- Can’t use chrome driver for Selenium
- Which of the 4 ways to call super() in Python 3 to use?
- How to properly use the “choices” field option in Django
- how to add a coroutine to a running asyncio loop?