本文介绍了有没有办法更改Pydev中所有运行配置的默认编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已经对或 / 我使用PyDev和I想要默认的开箱即用的Python行为(US-ASCII为默认(非)编码),因为我觉得这更安全(我不喜欢site_customize.py方法),即使更费力。

There has been some discussion of the merits or demerits/evilness of using sys.setdefaultencoding(...) in python 2.x I'm using PyDev and I want to have the default 'out of the box' python behaviour (US-ASCII as default (non-)encoding), as I feel this is safer (I don't like the site_customize.py approach), even if more laborious.

当我使用PyDev(特别是运行单元测试)时,它默认调用sys.setdefaultencoding('UTF-8')。其他答案建议在每个运行配置公共选项卡中将编码设置更改为US-ASCII。

When I'm using PyDev (particularly for running unittests) it be defaults calls sys.setdefaultencoding('UTF-8'). Other answers have recommended changing the encoding setting to 'US-ASCII' in each 'run configurations' Common tab.

我想将所有运行配置的默认更改为跨越pydev(每个工作区)的US-ASCII或至少全局一个Python解释器。有没有办法这样做?

I would like to change the default for all run configurations to 'US-ASCII' across pydev (per workspace) or at least globally for one Python interpreter. Is there a way to do this?

仔细研究了实现:Pydev使用PYDEV_CONSOLE_ENCODING环境变量来获取编码(这在...中的site_customize.py文件中org.python.pydev插件)。但是,这个似乎可以从运行配置下拉列表中的运行对话框的设置来设置。默认值为inherited - UTF-8,但是在pydev的设置中,我没有找到任何地方更改此内容。我已经尝试在各种场合设置环境变量PYDEV_CONSOLE_ENCODING,但是这还没有通过site_customize.py(而是从对话框选项卡上的Encoding设置中读取值)。

Having looked into the implementation: Pydev uses a PYDEV_CONSOLE_ENCODING environment variable to get the encoding (this is within the site_customize.py file in the org.python.pydev plugin). However this seems to be set from the setting of the run-dialog in the Run configurations drop down. The default says "inherited - UTF-8" but I haven't found anywhere to change this in pydev's settings. I've tried setting the environment variable PYDEV_CONSOLE_ENCODING in various places, but this hasn't got through to site_customize.py (instead it reads the value from the Encoding setting on the dialog tab).

推荐答案

您可以在窗口>首选项>常规>工作区>文本文件编码(将其设置为其他> us-ascii)中更改默认编码。

You can change the default encoding at window > preferences > general > workspace > text file encoding (set it to other > us-ascii).

这篇关于有没有办法更改Pydev中所有运行配置的默认编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 12:13
查看更多