[英]How to print Persian word in vscode terminal Python
我正在使用 vscode,當我嘗試打印這個時
print('شیرینی پزی')
終端的 output 是
یزپ ینیریش
我應該怎么辦
注意:以下解決方案用於顯示 RTL 文本。 不要在代碼中使用 output。 它僅用於在 RTL 文本混亂的地方打印。
首先安裝arabic_reshaper
和bidi
pip install arabic-reshaper
pip install python-bidi
然后,使用以下 function:
import arabic_reshaper
from bidi.algorithm import get_display
def convert(text):
reshaped_text = arabic_reshaper.reshape(text)
converted = get_display(reshaped_text)
return converted
print(convert('شیرینی پزی'))
output:
>>> شیرینی پزی
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.