parsing non-ascii characters

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ronn

    parsing non-ascii characters

    Hello all,

    I have a list:
    suffix = ["aĉ", "ad", "aĵ", "an", "ar"]

    and I'm trying to check a word to see if any of the suffixes exist in
    the list for example:
    if word in suffix:
    print "A suffix exist in your word"

    when I run this it give me an error:
    SyntaxError: Non-ASCII character '\xc5' in file vortaro.py on line
    33, but no encoding declared;

    is there a way to parse Non-ASCII characters in python?

    Thanks in advance,
    Ronn
  • John Machin

    #2
    Re: parsing non-ascii characters

    On Nov 10, 1:13 pm, Ronn <ronn.r...@gmai l.comwrote:
    Hello all,
    >
    I have a list:
      suffix = ["aĉ", "ad", "aĵ", "an", "ar"]
    >
    and I'm trying to check a word to see if any of the suffixes exist in
    the list for example:
      if word in suffix:
          print "A suffix exist in your word"
    >
    when I run this it give me an error:
       SyntaxError: Non-ASCII character '\xc5' in file vortaro.py on line
    33, but no encoding declared;
    Read this:
    Invoking the Interpreter: The Python interpreter is usually installed as/usr/local/bin/python3.14 on those machines where it is available; putting/usr/local/bin in your Unix shell’s search path mak...


    Read all of the tutorial.
    is there a way to parse Non-ASCII characters in python?
    This question is meaningless.

    Comment

    • =?GB2312?B?0rvK18qr?=

      #3
      Re: parsing non-ascii characters

      On Nov 10, 10:13 am, Ronn <ronn.r...@gmai l.comwrote:
      Hello all,
      >
      I have a list:
        suffix = ["aĉ", "ad", "aĵ", "an", "ar"]
      >
      and I'm trying to check a word to see if any of the suffixes exist in
      the list for example:
        if word in suffix:
            print "A suffix exist in your word"
      >
      when I run this it give me an error:
         SyntaxError: Non-ASCII character '\xc5' in file vortaro.py on line
      33, but no encoding declared;
      >
      is there a way to parse Non-ASCII characters in python?
      >
      Thanks in advance,
      Ronn
      This PEP proposes to introduce a syntax to declare the encoding of a Python source file. The encoding information is then used by the Python parser to interpret the file using the given encoding. Most notably this enhances the interpretation of Unicode ...

      Comment

      Working...