Convert Unicode escape sequences like \ u in Python

Overview

I wanted to convert a large file containing characters like \ u30d5, so I looked it up. If there are few characters, there is a WEB tool so there is no need to do it.

Source

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()

Recommended Posts

Convert Unicode escape sequences like \ u in Python
[Python] Expand escape sequences in here documents
Generate U distribution in Python
Convert CIDR notation in Python
Convert markdown to PDF in Python
Something like JS setTimeout in python
MySQL-automatic escape of parameters in python
Display characters like AA in python
Something like tail -f in Python
Find files like find on linux in Python
Note: [Python3] Convert datetime to a string in any format you like
Convert psd file to png in Python
Do something like Redis transactions in Python
Convert from Markdown to HTML in Python
Try something like Python for-else in Ruby
Convert absolute URLs to relative URLs in Python
Convert FBX files to ASCII <-> BINARY in Python
Convert PDFs to images in bulk with Python
Convert exponential notation float to str in Python
String to Unicode Escape Sequence Format for Python
Convert cubic mesh code to WKT in Python
Quadtree in Python --2
Python in optimization
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
SendKeys in Python
Meta-analysis in Python
Unittest in python
Epoch in Python
Discord in Python
Sudoku in Python
DCI in Python
quicksort in python
nCr in python
N-Gram in Python
Programming in python
Plink in Python
Constant in python
Lifegame in Python.
FizzBuzz in Python
Sqlite in python
StepAIC in Python
N-gram in python
LINE-Bot [0] in Python
Csv in python
Disassemble in Python
Reflection in Python
Constant in python
nCr in Python.
format in python
Scons in Python3
Puyo Puyo in python
python in virtualenv
PPAP in Python
Quad-tree in Python
Reflection in Python
Chemistry in Python
Hashable in python
DirectLiNGAM in Python