so this is my first time here, and also I am new to the world of Python. I am studying Chinese also and I wanted to create a program to review Chinese vocabulary using a dictionary. Here is the code that I normally use:
#!/usr/bin/python
# -*- coding:utf-8-*-
dictionary = {"Hello" : "你好"} # Simple example to save time
print(dictionary)
The results I keep getting are something like:
{'hello': '\xe4\xbd\xa0\xe5\xa5\xbd'}
I have also trying adding a “u” to the beginning of the string with the Chinese characters, and even the method “.encode(‘utf-8’), yet no of these seem to work. I normally work off of the Geany IDE. I have tried to check out all of the preferences, and I have read the PEP web page along with many of the other questions posted. It is funny, it works with strings and the raw_input method, but nothing else…
When printing a dict, (e.g.
print(dictionary)), thereprs of the keys and values are displayed.Instead, try:
yields: