Fw: [問題] systemd python stdout encode變成ANSI
※ [本文轉錄自 Linux 看板 #1Q6jQtYu ]
作者: walelile (wakaka) 看板: Linux
標題: [問題] systemd python stdout encode變成ANSI
時間: Sun Nov 26 22:59:00 2017
在嘗試用systemd來掛載python3 script
碰到systemd會使python3 sys.stdout.encode變成ANSI
當有中文的時候就會出現fail
請問是否可以讓sys.stdout.encode保持utf-8?
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.171.160.122
※ 文章網址: https://www.ptt.cc/bbs/Linux/M.1511708343.A.8B8.html
※ 發信站: 批踢踢實業坊(ptt.cc)
※ 轉錄者: walelile (1.171.160.122), 11/26/2017 23:26:16
→
11/26 23:28,
8年前
, 1F
11/26 23:28, 1F
→
11/26 23:29,
8年前
, 2F
11/26 23:29, 2F
→
11/26 23:29,
8年前
, 3F
11/26 23:29, 3F
感謝u大!
以下是我目前的locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
機器是Debian 9.2,我有嘗試用dkpg-reconfigure locales去安裝中文,但沒效果。
如果用以下修改sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())
stdout的部分不會跳Exception,但依然無法中文
而且讀中文檔案依然會掛...
※ 編輯: walelile (1.171.160.122), 11/26/2017 23:49:53
→
11/27 00:01,
8年前
, 4F
11/27 00:01, 4F
→
11/27 00:01,
8年前
, 5F
11/27 00:01, 5F
→
11/27 00:02,
8年前
, 6F
11/27 00:02, 6F
這是我的user session,原來systemd有自己的session!
有空再研究一下,今天一整個晚上都在弄systemd,最後還是只能回去nohup QQ
※ 編輯: walelile (1.171.160.122), 11/27/2017 00:19:08
→
11/27 01:32,
8年前
, 7F
11/27 01:32, 7F
→
11/27 02:22,
8年前
, 8F
11/27 02:22, 8F


現在可以print 中文 & 讀寫中文檔案
※ 編輯: walelile (1.171.160.122), 11/27/2017 03:23:16
※ 編輯: walelile (1.171.160.122), 11/27/2017 03:23:45