python2 series / 3 series, character code and print statement / command line

python2 series

Declaration

>>> text = 'text'
>>> btext = b'text'
>>> utext = u'text'

output

>>> text
'\xe3\x83\x86\xe3\x82\xad\xe3\x82\xb9\xe3\x83\x88'

>>> print text
text

>>> btext
'\xe3\x83\x86\xe3\x82\xad\xe3\x82\xb9\xe3\x83\x88'

>>> btext.decode('utf-8')
u'\u30c6\u30ad\u30b9\u30c8'

>>> print btext.decode('utf-8')
text

>>> print btext
text

>>> utext
u'\u30c6\u30ad\u30b9\u30c8'

>>> print utext
text

python3 series

Declaration

>>> text = 'text'
>>> btext = b'text'
  File "<stdin>", line 1
SyntaxError: bytes can only contain ASCII literal characters.

>>> utext = u'text'

output

>>> text
'text'

>>> print(text)
text

>>> utext
'text'

>>> print(utext)
text

Recommended Posts

python2 series / 3 series, character code and print statement / command line
python character code
Links and memos of Python character code strings
About Python3 character code
3-3, Python strings and character codes
Python 2 series and 3 series (Anaconda edition)
python> print> N line breaks> print ('\ n'* 3)> 4 line breaks> print ('\ n'* 3),> 3 line breaks
2.x, 3.x character code of python
Character code learned in Python
Command line argument processing (Python docopt)
About installing Pwntools and Python2 series
[Introduction to Python] How to output a character string in a Print statement
Print with python3 without line breaks
After updating to MacOS Catalina, install Xcode Command Line Tools and change from Python 2.7 series to 3.7 series (bash)
[Code] Module and Python version output
Difference between python2 series and python3 series dict.keys ()
[Python] Summary of conversion between character strings and numerical values (ascii code)
Get options in Python from both JSON files and command line arguments
python> Copy and paste code> SyntaxError: Non-ASCII character'\ xe3' in file>-*-coding: utf-8-*-Add
Installation of Visual studio code and installation of python
Fourier series verification code written in Python
[Python] What is pandas Series and DataFrame?
python> link> strftime () and strptime () behavior / code
Line graphs and scale lines in python
Decompose command arguments in one line in Python
Shell command to visualize line feed code
[Python] Get the character code of the file
Easy introduction of python3 series and OpenCV3
Character code for reading and writing csv files with python ~ windows environment ver ~
Character code
Template for creating command line applications in Python
How to receive command line arguments in Python
Quickly display the QR code on the command line
[Python] [chardet] Automatic detection of character code of file
Load and execute command from yml in python
[Short sentence] [Python] Format and print lists and dictionaries
My thoughts on python2.6 command line app template
Notify error and execution completion by LINE [Python]
[Introduction to Udemy Python3 + Application] 67. Command line arguments
List of Python code to move and remember
Convert the character code of the file with Python3
Basic operation of Python Pandas Series and Dataframe (1)
If you can't send an email with python smtplib and have trouble, command line