开发者

How to generate hebrew strings in python 3?

开发者 https://www.devze.com 2023-01-12 01:48 出处:网络
I\'m trying to create hebrew strings but get syntax errors. It works in the IDLE shell but not in Pydev.

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("מחרוזת בעברי开发者_JS百科ת", "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).

0

精彩评论

暂无评论...
验证码 换一张
取 消