Remove double-byte spaces before and after the character string (python)

It is a small story.

test.py


line = 'Today's weather is sunny'
NG_example = line.strip()    # 'Today's weather is sunny'
OK_example = unicode(line).strip()    # u'Today's weather is sunny'
OK_example2 = line.decode('utf-8').strip().encode('utf-8')    # 'Today's weather is sunny'

Recommended Posts

Remove double-byte spaces before and after the character string (python)
[python] plot the values ​​before and after the conversion of yeojohnson conversion
Divides the character string by the specified number of characters. In Ruby and Python.
Rotate and scale the image before cropping [python] [OpenCV]
[Python3] Format the character string using the variable name as the key.
3-3, Python strings and character codes
Python indentation and string format
Date and time ⇔ character string
[Python 2/3] Parse the format string
Python f character (formatted string)
[Introduction to Python] How to split a character string with the split function
Notify the contents of the task before and after executing the task in Fabric
The story of Python and the story of NaN
python string processing map and lambda
Python> Slice> A slice offset earlier than the beginning of a string is treated as 0, and one after the end is treated as -1
How to input a character string in Python and output it as it is or in the opposite direction.
Fill the string with zeros in python and count some characters from the string
Insert processing before and after the view function in Pyramid's own View Decorator
[Introduction to Python] How to write a character string with the format function
[Introduction to Python] Thorough explanation of the character string type used in Python!
Python UTC ⇔ JST, character string (UTC) ⇒ JST conversion memo
# 5 [python3] Extract characters from a character string
[Python] How to invert a character string
[Python beginner memo] Python character string, path operation
Sh and py run after installing Python3
[Pandas] Expand the character string to DataFrame
Basic grammar of Python3 system (character string)
Academia Potter and the Mysterious Python Pass
[Python] Get the character code of the file
python> link> remove CR, LF>'test string \ n'.rstrip ()
Python basic course (4 numeric type / character string type)
[PowerShell] Get the reading of the character string
Python open and io.open are the same
Fill the missing value (null) of DataFrame with the values before and after with pyspark
[AWS] Detects the specified character string from the Lambda execution log and notifies slack
Python version (PHP to Python) that deletes the subsequent character string from the specified character string (extension)
Get the last element of the array by splitting the string in Python and PHP