Qpython unicode strings

2019-07-12 03:05发布

问题:

I'm trying to port a Python 3.5 project from PC to Android QPython3 but for the line:-

if ch = in u'\x00\xe0':
    ch = getwch()

I'm getting this when I run it:-

if ch = in u'\x00\xe0':
                ^
  SyntaxError: invalid syntax

I thought QPython3 was supposed to run all 3.x scripts and the Unicode 'u' prefix isn't a new addition so what can the problem be? Are hex numbers in strings treated differently?

回答1:

To answer my own question, after much fiddling about I got it to work using:-

if ch in bytes([0x00, 0xe0]):

instead.