you’re going to have to ‘encode’ the unicode string.
s = u'\u5E73\u621015' with open("yop", "wb") as f: f.write(s.encode("UTF-8"))
try this out for a bit of a friendly look at unicode and python: http://farmdev.com/talks/unicode/
Related Posts:
- How to resolve TypeError: can only concatenate str (not “int”) to str [duplicate]
- How to correct TypeError: Unicode-objects must be encoded before hashing?
- How to remove \xa0 from string in Python?
- What does the ‘b’ character do in front of a string literal?
- What does the ‘b’ character do in front of a string literal?
- (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: truncated \UXXXXXXXX escape
- (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: truncated \UXXXXXXXX escape
- “Unicode Error “unicodeescape” codec can’t decode bytes… Cannot open text files in Python 3
- Python – ‘ascii’ codec can’t decode byte
- UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\xa0′ in position 20: ordinal not in range(128)
- Python string prints as [u’String’]
- NameError: global name ‘unicode’ is not defined – in Python 3
- Convert a Unicode string to a string in Python (containing extra symbols)python string unicode type-conversion
- Using unicode character u201c
- What is a unicode string?
- Convert Unicode to ASCII without errors in Python
- TypeError: coercing to Unicode: need string or buffer, int found
- UnicodeDecodeError, invalid continuation byte
- What exactly do “u” and “r” string flags do, and what are raw string literals?
- How to iterate over rows in a DataFrame in Pandas
- How to convert list to string [duplicate]
- How to uninstall a package installed with pip install –user
- numpy max vs amax vs maximum
- TypeError: ‘str’ object is not callable (Python)
- ValueError: invalid literal for int() with base 10: ”
- ModuleNotFoundError: No module named ‘sklearn’
- Does Python have an ordered set?
- Asking the user for input until they give a valid response
- Print a list in reverse order with range()?
- Configuring so that pip install can work from github
- Proper way to declare custom exceptions in modern Python?
- TypeError: ‘float’ object not iterable
- write() versus writelines() and concatenated strings
- Why is it string.join(list) instead of list.join(string)?
- Importing class from another file [duplicate]
- Pandas group-by and sum
- How to read a .xlsx file using the pandas Library in iPython?
- Numpy/Python Array Value error
- Changing the “tick frequency” on x or y axis in matplotlib?
- TypeError: unsupported operand type(s) for -: ‘str’ and ‘str’
- Remove all special characters, punctuation and spaces from string
- AttributeError: ” object has no attribute ”
- Plot pie chart and table of pandas dataframe
- ModuleNotFoundError: No module named ‘matplotlib’
- “inconsistent use of tabs and spaces in indentation”
- Pandas ‘count(distinct)’ equivalent
- How can I flush the output of the print function?
- Python calling method in class
- No module named pkg_resources
- Opening a .ipynb.txt File
- How do I remove all packages installed by PIP?
- TypeError: list indices must be integers or slices, not str
- python object() takes no parameters error
- How do I find the distance between two points?
- How do I calculate percentiles with python/numpy?
- How do I remove a substring from the end of a string?
- Selecting with complex criteria from pandas.DataFrame
- How can I download Anaconda for python 3.6
- django:django.core.exceptions.AppRegistryNotReady: Apps aren’t loaded yet
- Replace and overwrite instead of appending
- module ‘pandas’ has no attribute ‘rolling_mean’
- How to make a histogram from a list of data
- Using __add__ operator with multiple arguments in Python
- How to constantly run Python script in the background on Windows?
- Django – “no module named django.core.management”
- Type error Unhashable type:set
- Saving a Numpy array as an image
- Windows path in Python
- Python: ValueError: Mixing iteration and read methods would lose data
- python: restarting a loop
- “for loop” with two variables?
- Python: urllib.error.HTTPError: HTTP Error 404: Not Found
- Display number with leading zeros
- Running Python in PowerShell?
- Why do many examples use `fig, ax = plt.subplots()` in Matplotlib/pyplot/python
- ImportError: No module named model_selection
- Numpy – add row to array
- How to change pip installation path
- What is the difference between a string and a byte string?
- “This constructor takes no arguments” error in __init__
- plot a circle with pyplot
- Rolling or sliding window iterator?
- What is a namespace object?
- How to serve static files in Flask
- How to create Gephi network graphs from Python?
- strncmp in python
- How can I count time in Python 3?
- Using strip() to clean up a string
- How to install PyQt4 on Windows using pip?
- How to install PyQt4 on Windows using pip?
- python dictionary error AttributeError: ‘list’ object has no attribute ‘keys’
- What is a mixin, and why are they useful?
- What is the most efficient way to store a list in the Django models?
- Convert list of dictionaries to a pandas DataFrame
- How to read html from a url in python 3
- Set variable in jinja
- Python how to write to a binary file?
- How to download a file via FTP with Python ftplib
- How do I restart a program based on user input?
- Python Pandas : pivot table with aggfunc = count unique distinct