Links and memos of Python character code strings

About character code

"Character code story" that newcomers should know

There are two types: coded character set and character encoding method.

Encoded character set

Character and code point mapping

--Example: unicode, ascii --Default unicode in python3


>>> hex(ord("Ah"))
'0x3042' #unicode"Ah"Code point

Character encoding method

Character operation method, implementation method

--Example: utf-8, shift-jis, euc-jp -"A" becomes a different byte sequence when encoded with utf-8 and utf-16

Handling of characters in Python 3

Keep in mind when processing strings with Python3

--The literal of 'ah' is a unicode string --When converting to bytes 'Ah'.encode ('utf-8') --When converting bytes back to unicode, bytes_moji.decode ('utf-8') --The function is different when writing to a file with unicode and when writing with byte and reading. -Handling of character codes in Python

For the time being, handling with python2

Keep in mind when processing strings with Python2

--In python2, byte conversion is done by default ascii --When trying to convert a Japanese string to a file, an error occurs when trying to encode to byte with the default ascii --must be specified to encode with utf-8

Recommended Posts

Links and memos of Python character code strings
3-3, Python strings and character codes
2.x, 3.x character code of python
python character code
[Python] Get the character code of the file
[Python] Various combinations of strings and values
[Introduction to Udemy Python3 + Application] 12. Indexing and slicing of character strings
About Python3 character code
List of Python code to move and remember
Convert the character code of the file with Python3
[Python] Chapter 02-02 Basics of Python programs (Handling of character strings)
Mayungo's Python Learning Note: List of stories and links
python2 series / 3 series, character code and print statement / command line
[Python] Extract only numbers from lists and character strings
Character code learned in Python
Source installation and installation of Python
The process of making Python code object-oriented and improving it
Mass generation of QR code with character display by Python
Spit out a list of file name, last modified date and character code in python3
Environment construction of python and opencv
The story of Python and the story of NaN
Installation of SciPy and matplotlib (Python)
[Python] [Table of Contents Links] Python Programming
[Code] Module and Python version output
This and that of python properties
[Beginner] Extract character strings with Python
Features of symbolic and hard links
Coexistence of Python2 and 3 with CircleCI (1.0)
[Excel] Addition of character strings (combination)
Summary of Python indexes and slices
Reputation of Python books and reference books
Change the length of Python csv strings
Handling of character code of file in IronPython
python> link> strftime () and strptime () behavior / code
Extraction of tweet.js (json.loads and eval) (Python)
Connect a lot of Python or and and
[Python3] Rewrite the code object of the function
Character code
[Introduction to Udemy Python3 + Application] 11. Character strings
python> Copy and paste code> SyntaxError: Non-ASCII character'\ xe3' in file>-*-coding: utf-8-*-Add
Basic grammar of Python3 system (character string)
Bulk replacement of strings in Python arrays
Python code to train and test with Custom Vision of Cognitive Service
Easy introduction of python3 series and OpenCV3
Idempotent automation of Python and PyPI setup
Full understanding of Python threading and multiprocessing
Example of python code for exponential distribution and maximum likelihood estimation (MLE)
Project Euler # 1 "Multiples of 3 and 5" in Python
Divides the character string by the specified number of characters. In Ruby and Python.
List of main probability distributions used in machine learning and statistics and code in python
Character code for reading and writing csv files with python ~ windows environment ver ~
[Python] Read the source code of Bottle Part 2
Correspondence summary of array operation of ruby and python
Summary of the differences between PHP and Python
[python] Create a list of various character types
The answer of "1/2" is different between python2 and 3
Specifying the range of ruby and python arrays
Installation of Python3 and Flask [Environment construction summary]
Character encoding when using csv module of python 2.7.3
Compare the speed of Python append and map
[Python] Chapter 02-01 Basics of Python programs (operations and variables)