在可能的情况下,我想使用unicode python字符串u"\U0001d54d"
,但是如果在显示它时出现问题,我只想使用一个“V”。你知道吗
在某些系统上,unicode打印。
在其他情况下,它什么也不显示(我假设发生了.encode("ascii","ignore")
类型的事情),或者
UnicodeEncodeError: 'ascii' codec can't encode character u'\U0001d54d' in position 14: ordinal not in range(128)
根据功能。。。两者都不好。你知道吗
有没有一个测试,我可以做,以确定是否使用我的特殊字符?还是比这更复杂?你知道吗
引用Python术语表
Python中处理运行时错误的标准方法是try\except。
try
打印字符串,并except UnicodeEncodeError
在出现错误时进行回退。你知道吗您可以轻松检查stdout支持什么编码:
显示部分取决于要打印的位置。Python将输出编码为终端应用程序正在使用的任何编码。您可以检查环境变量以确保字符是在您需要的区域设置中定义的,例如:
同时检查
LC_CTYPE
相关问题 更多 >
编程相关推荐