SyntaxError: (unicode error) 'unicodeescape

2019-03-05 04:19发布

I have issues with an python script. When I run it I has this error:

 ./ics2owncloud.py
  File "./ics2owncloud.py", line 46
    if r.status_code == 500 and 'Sabre\VObject\Recur\NoInstancesException' in r.text:
                                   ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 19-20: malformed \N character escape

This is the script: https://github.com/buzz/ics2owncloud.py

I used python3 not 2.7 at the original script.

标签: python shell
1条回答
劫难
2楼-- · 2019-03-05 05:19

Try changing all of the \ to \\, or put an r in front of the string, e.g.,

if r.status_code == 500 and r'Sabre\VObject\Recur\NoInstancesException' in r.text:
                         #  ^ that right there

In general, though, running Python 2.7 code with Python 3 (or vice versa) will almost certainly not work! They are not directly compatible. Stick with 2.7 if that's what your scripts were written for.

In the meantime, welcome to the site! Check out the Stack Overflow tour for more on asking questions that will attract quality answers.

查看更多
登录 后发表回答