简体   繁体   English

python中的特殊字符问题

[英]Special characters issue in python

I have a problem about this code 我对此代码有疑问

def print_text(text):
 print text

#---------- excut cod -----------
print_text("Dêqên Tibetan")
#---------- end cod -------------

When I run from pyscripter, application only shows 当我从pyscripter运行时,应用程序仅显示

D?q?n Tibetan

how do I fix it? 我如何解决它?

This is after press play > 这是按播放后>

enter image description here error 在此处输入图片描述 错误

just do 做就是了

print u"Dêqên Tibetan"

in python 2 or 在python 2或

print(u"Dêqên Tibetan")

in python 3 在python 3中

当您传递参数值时,您将使用Unicode字母[u]:

print_text(u"Dêqên Tibetan")

another way: 其他方式:

def print_text(text):
   print unicode(text, "utf-8") # you can use other encode

print_text("Dêqên Tibetan")

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

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