![](/img/trans.png)
[英]I want to get rid of all the special characters like [(' and im really stuck in how to
[英]How to get characters like '┌' and '─' on ubuntu?
我的計算機上同時裝有Windows和Ubuntu,並且在Ubuntu上使用python3。 我是python編程的新手,這是問題所在:
if access == 1:
print("\n" * 100)
print("┌──────────────────────────────┐")
time.sleep(0.1)
print("│ │")
time.sleep(0.1)
print("│ Welcome to the Viktoracri │")
time.sleep(0.1)
print("│ system database │")
time.sleep(0.1)
print("│ │")
time.sleep(0.1)
print("├──────────────────────────────┤")
time.sleep(0.1)
print("│ │")
time.sleep(0.1)
print("│ Logged in as: %s │" % u)
time.sleep(0.1)
print("│ │")
time.sleep(0.1)
print("│ You are now logged in to the │")
time.sleep(0.1)
print("│ Viktoracri system database. │")
time.sleep(0.1)
print("│
如果有幫助,請在腳本頂部添加以下內容:
#!/usr/bin/python
# -*- coding: latin-1 -*-
當我運行代碼時,那些字符“┐”和“│”確實表現得很糟糕。
請幫忙? 我擁有的字符來自Windows字符映射。
您的終端設置為latin-1
(或我的盒子上的ISO-8859-1):
>>>print "├──────────────────────────────┤".decode('iso8859')
ââââââââââââââââââââââââââââââââ¤
>>>print "├──────────────────────────────┤".decode('utf8')
├──────────────────────────────┤
解決方法是更改終端編碼,以便正確顯示字符。 我可以通過在utf-8
和latin-1
之間交換終端編碼來在本地復制/修復您的問題
您可以嘗試更改標准輸出的編碼
import sys
import codecs
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
如果不起作用,則可以嘗試將環境變量“ PYTHONIOENCODING”更改為“ utf_8”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.