но не работает, если просто запустить модуль из cmd.
Видает ошибку:
UnicodeDecodeError: ‘ascii’ codec can't decode byte 0xc7 in position 73: ordinal not in range(128)
Так в чем же отличие запуска из PyDev и из cmd ?
Попробовал поменять в модуле site.py encoding c “ascii” на “cp1251”
def setencoding(): """Set the string encoding used by the Unicode implementation. The default is 'ascii', but if you're willing to experiment, you can change this.""" encoding = "ascii" # Default value set by _PyUnicode_Init() if 0: # Enable to support locale aware default string encodings. import locale loc = locale.getdefaultlocale() if loc[1]: encoding = loc[1] if 0: # Enable to switch off string to Unicode coercion and implicit # Unicode to string conversion. encoding = "undefined" if encoding != "ascii": # On Non-Unicode builds this will raise an AttributeError... sys.setdefaultencoding(encoding) # Needs Python Unicode build !
Но возникает вопрос: где в PyDev хранятся эти настройки кодирования?
И можно ли изменить encoding на “cp1251” во время исполнения моего модуля не изменяя site.py ?