简体   繁体   中英

How to generate hebrew strings in python 3?

I'm trying to create hebrew strings but get syntax errors. It works in the IDLE shell but not in Pydev. Here's what I've tried so far:

s = 'מחרוזת בעברית' #works in the shell only
s = u'מחרוזת בעברית' #doesn't work at all
s = unicode("מחרוזת בעברית", "UTF-8") #also doesn't work at all

I get a syntax error: Non-UTF-8 code starting with '\\xee'. What does it mean and what shall I do to create hebrew strings?

Does your source file start with a # -*- coding: utf-8 -*- line? Is your file actually encoded as utf-8 (and not some other encoding)?

It's supposed to work (the first line, other lines are not valid Python 3).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM