简体   繁体   English

为什么PyCharm显示无效的unicode字符?

[英]Why does PyCharm show invalid unicode characters?

I want to process a unicode UTF-8 text in PyCharm. 我想在PyCharm中处理Unicode UTF-8文本。 The characters in the csv file are saved in Excel 2016 as UTF-8 unicode. csv文件中的字符在Excel 2016中另存为UTF-8 Unicode。 However, when i try to write in unicode on the code input area or when i output the result in the console, it gives me invalid characters. 但是,当我尝试在代码输入区域上编写unicode或在控制台中输出结果时,它给了我无效字符。 Also I am not able to write in unicode characters on PyCharm, How can i fix this? 我也无法在PyCharm上用unicode字符书写,我该如何解决?

import pandas as pd

data1=pd.read_csv('Feb2018_Payroll.csv',encoding='utf-8')
print(data1)

When i copy paste the console output here (below), it looks fine. 当我复制粘贴控制台输出到这里(如下)时,看起来不错。 However, in the console it's invalid characters. 但是,在控制台中,它是无效字符。 What could be the reason and how can i solve it? 可能是什么原因,我该如何解决?

   ተ.ቁ.      የሠራተኛ ስም       የሰሩበት ቀን         የወር ደሞዝ         የኃላፊነት አበል  
0    1.0      ገ/መድህን     30.0            4000.00          250.0   
1    2.0     በቀለ       30.0            2000.00            NaN   
2    3.0     ሽፈራው      30.0            3000.00            NaN   

So as for now, PyCharm for Mac uses only 16 bits for the Unicode character code. 因此,到目前为止,Mac的PyCharm仅将16位用于Unicode字符代码。 So this PyCharm for Mac only shows characters in the Basic Multilingual Plane (BMP). 因此,此Mac版PyCharm仅在基本多语言平面(BMP)中显示字符。 As a result, characters that use more than 16 bits are shown as blanks. 结果,使用多于16位的字符显示为空白。

With that being said, there are other Intellij derivatives that already display the full range of Unicode characters (32-bit). 话虽这么说,还有其他Intellij派生类已经显示了所有Unicode字符(32位)。 One example is the Android Studio for Mac. 一个示例是适用于Mac的Android Studio。

Solution: If Hindi Chars are not showing in pycharm go to 解决方案:如果pycharm中未显示北印度语字符,请转到

File>Settings>Editor>FileEncoding 文件>设置>编辑> FileEncoding

Select UTF-8 Everywhere and at last select with BOM option. 选择UTF-8 Everywhere,最后选择带BOM选项。

[File Encoding in PyCharm Community Edition 2018.3 1 [PyCharm Community Edition 2018.3中的文件编码1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM