LoginSignup
2
2

More than 5 years have passed since last update.

\uみたいなUnicodeエスケープシーケンスをPythonで変換する

Posted at

概要

\u30d5みたいな文字が入っている大きいファイルの変換をやりたかったので調べました。少ない文字だったらWEBツールがあるのでやる必要はないです。

ソース

py
# coding: utf-8
import codecs
fin  = codecs.open('C:/tmp/a1.txt', 'r')
fout  = codecs.open('C:/tmp/a2.txt', 'w', 'sjis')
for line in fin:
    s  = line.decode("unicode-escape")
    fout.write(s)
fin.close()
fout.close()

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2