This works for me:
#!/usr/bin/env python
# define source file encoding, see: http://www.python.org/dev/peps/pep-0263/
# -*- coding: utf-8 -*-
import urllib
url = u'http://example.com/índice.html'
content = urllib.urlopen(url.encode("UTF-8")).read()
More Related Contents:
- What exactly do “u” and “r” string flags do, and what are raw string literals?
- What does the ‘b’ character do in front of a string literal?
- How to remove \xa0 from string in Python?
- How to get string objects instead of Unicode from JSON?
- Why does Python print unicode characters when the default encoding is ASCII?
- Get a list of all the encodings Python can encode to
- Non-ASCII characters in Matplotlib
- What is the difference between encode/decode?
- Conversion of strings like \\uXXXX in python
- urllib2 read to Unicode
- ‘UCS-2’ codec can’t encode characters in position 1050-1050
- Why doesn’t Python recognize my utf-8 encoded source file?
- Python 3 print() function with Farsi/Arabic characters [duplicate]
- How to make Django slugify work properly with Unicode strings?
- Python 3: How to specify stdin encoding
- Python – Unicode to ASCII conversion
- Identifier normalization: Why is the micro sign converted into the Greek letter mu?
- How do I treat an ASCII string as unicode and unescape the escaped characters in it in python?
- What does ‘u’ mean in a list?
- Saving UTF-8 texts with json.dumps as UTF-8, not as a \u escape sequence
- Error “(unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: truncated \UXXXXXXXX escape” [duplicate]
- How is unicode represented internally in Python?
- Unicode identifiers in Python?
- Printing a string prints ‘u’ before the string in Python?
- How does unicodedata.normalize(form, unistr) work?
- Python – dealing with mixed-encoding files
- Python: How can I replace full-width characters with half-width characters?
- Python the same char not equals
- Python 3 chokes on CP-1252/ANSI reading
- How to make print() output UTF-8 in Python 3.0?