How can I print a string as a sequence of Unicode codes in Python?
Entrance: ""(in Russian).
""
Output: "\u0435\u0441\u043b\u0438"
"\u0435\u0441\u043b\u0438"
This should work:
>>> s = u'' >>> print repr(s) u'\u0435\u0441\u043b\u0438'
the code:
txt = u"" print repr(txt)
Output:
u'\u0435\u0441\u043b\u0438'
a = u"\u0435\u0441\u043b\u0438" print "".join("\u{0:04x}".format(ord(c)) for c in a)
If you need a specific encoding, you can use:
txt = u'' print txt.encode('utf8') print txt.encode('utf16')
Source: https://habr.com/ru/post/1731525/More articles:extract date from datetime column - mysqlResponding to the back and forward buttons in WPF - wpfPython 2 dimensional set / list search - pythonHow to iterate through C # class attributes (.NET 2.0)? - jsonWhat is the point of having 2 stylesheets for a layout for a style? - user-interfaceSharePoint QuickLaunch and TopNavigationBar disappear - loggingHow to make a sql quit job step fail - tsqlProblem with nesting in Text.XHtml library using Haskell - xhtmlFloating div in html page - javascriptWymeditor through subdomains. (Problem with resolved resolution). - javascriptAll Articles