V
V
Vitaly2015-11-06 17:42:41
Python
Vitaly, 2015-11-06 17:42:41

How to deal with cyrillic in python?

Once I learned python a little, then I moved away from it, now I needed to write several scripts in that language, but I ran into a problem:

SyntaxError: Non-ASCII character '\xd1' in file  ...

the problem is in the encoding, but for some reason
# -*- coding: utf-8 -*-
they
#coding: utf8
don’t solve it :(
Python 2.7

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
angru, 2015-11-06
@angru

You have a SyntaxError, I suspect that you dared to use Cyrillic in the variable/function name. You can't do that.
PS It is considered good manners to publish a full stack trace.

V
Vitaliy, 2015-11-06
@Scorpiored88

import hashlib
import sys
from transliterate import translit
import datetime


def lk_name(lk):
    return lk.replace('ь' , '').replace('э' , 'e').replace('е' , 'e').replace('ы' , 'i').replace('ы' , 'y').replace(' ' , '_')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question