By default, the python 2.7 on Ubuntu/Debian is using ascii as default encoding. There is an option in /usr/lib/python2.7/site.py, user can enable to support locale aware default string encodings, which is a system wide setting.
The better approach is to switch the default encoding to user's setting. Like
import locale
encoding = 'ascii'
loc = locale.getdefaultlocale()
if loc[1]:
encoding = loc[1]
By default, the python 2.7 on Ubuntu/Debian is using ascii as default encoding. There is an option in /usr/lib/ python2. 7/site. py, user can enable to support locale aware default string encodings, which is a system wide setting.
The better approach is to switch the default encoding to user's setting. Like
import locale getdefaultlocal e()
encoding = 'ascii'
loc = locale.
if loc[1]:
encoding = loc[1]
sys.setdefaulte ncoding( encoding)