Str.rc
一個關於法語的字串檔案在這裡:
ID_STR_BRIGHTNESS;,"Luminosité"
ID_STR_CHILE_EASTER_ISLAND;,"Île de Pâques"
ID_STR_CURRENT_CH;,"Saisie chaîne"
ID_STR_DETAILS;,"Détails"
.....
現在我可以將其匯出到 Microsoft Str.xls
,如下所示:
cat ./Str.rc | sed 's/.*,//g' > ./Str.xls
但它會以這種方式從“詳細信息”中獲取“詳細信息”。
順便說一句,我嘗試透過命令獲取文件 Str.rc 編碼格式:enca Str.rc
,它返回如下:
enca: Cannot determine (or understand) your language preferences.
Please use `-L language', or `-L none' if your language is not supported
(only a few multibyte encodings can be recognized then).
Run `enca --list languages' to get a list of supported languages.
那麼,我能為此做些什麼呢?
答案1
您或許可以調整您的 Unix 工具來正確處理編碼。但是,如果您只想使用 Python 刪除“,”之前的資料:
with open('Str.xls', 'w') as ofp:
with open('Str.rc') as fp:
for line in fp:
ofp.write(line.split(',',1)[1])
如果您想從命令列運行它而不先將其保存為文件,您可以剪切並貼上:
python -c "with open('Str.xls', 'w') as ofp:
with open('Str.rc') as fp:
for line in fp:
ofp.write(line.split(',',1)[1])"