Pourquoi ne pas mettre ʻusercustomize.py avant de mettre
sitecustomize.py`?
python
>>> import site
>>> userdir = site.getusersitepackages()
windows
>>> userdir()
'C:\\Users\\owner\\AppData\\Roaming\\Python\\Python27\\site-packages'
ubuntu
>>> userdir()
'/home/owner/.local/lib/python2.7/site-packages'
mac
>>> userdir()
'/Users/owner/Library/Python/2.7/lib/python/site-packages'
windows
>>> os.makedirs(userdir)
>>> os.system('explorer.exe %s' % userdir)
1
windows
>>> f = open("%s\\usercustomize.py" % userdir,"w")
>>> str="""import sys
... sys.setdefaultencoding('utf-8')
... """
>>> f.write(str)
>>> f.close()
python
>>> import sys
>>> sys.getdefaultencoding()
'utf-8'
En cas d'échec, ʻascii` s'affiche.
Recommended Posts