I want to remove \u00a9 , \u201d and characters like that from my string in given dictionary (python). -


After text "itemprop =" text ">

  d = {" key ":" Playing Cards \ u00a9 Personalized Coaster "impresses the game crowd with these classic "This beautiful glass is made of glass, and weighs about 4 \ u201d x 4 \ u201d (inches)" to touch, and to look beautiful. There are 4 casters in one set. All card lovers Designed for this exclusive design, each coaster has a different suit, with the bottom. Make uber-personal! "HerOccasion": "It will look like a couple, great bar, or made for tabletop.Gift": Diwali, Bridge, Anniversary, Birthday "}  

I have tried to replace the function but did not work on it. Text after

  s = d [key] .replace ('\ u00a9', '')  

If you want to remove all Unicode characters from a string, you can use string.encode (" ascii "," ignore ") .

The ASCII tries to convert the string to the encoding, and the second parameter is the characters that can not be changed (all Unicode characters) to ignore Throwing instead of neglect is an exception because it normally occurs without the second parameter, so it gives a string that can be successfully converted, thus eliminating all unicode characters.

Example Usage:

  unicodeString = "Hello stackoverflow" print (unicodeString.encode ("ascii", "ignore")) # print 'HLL StckOvrflow'  

More information: and in Python documentation.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -