Alpagut
Alpagut

Reputation: 1173

Unsupported characters in input

I want to assign a string of characters to a variable but it says

: there isn't a "code to show.

I have a string that i want to assign to a variable

d="stunning:/ËstÊnɪÅ/"
Unsupported characters in input

or

word="stuning:/ˈstraɪkɪŋ/"
Unsupported characters in input

so basically the interpreter doesn't allow me to assign it to a variable, so I can't code on it.

How can I extract, delete those characters from the text, or is there anything to do , so python will support this kind of input.

I've tried to converted it into others format like ansi, utf, etc. but without success.

P.S.: I'm using python 2.7

Upvotes: 5

Views: 11798

Answers (2)

Andrea Spadaccini
Andrea Spadaccini

Reputation: 12651

Set the source file encoding accordingly to the actual encoding of the file, so that the interpreter knows how to parse it.

For instance, if you use UTF-8, just add this string to the header of the file:

    # -*- coding: utf8 -*-

It must be the first or the second line of the file. See PEP 0263: Defining Python Source Code Encodings.

Upvotes: 8

Don
Don

Reputation: 17616

Just a hint (waiting for the actual code): prepend u to the string to mark it as unicode.

u"/ËstraɪkɪÅ/"

Upvotes: 2

Related Questions