I know that first line of python file always give the info of encoding.
But I don't know  even than the first line words are encoded with specific encoding, how does editor know the correct encoding of the first line words.
thanks for you reply
I don't believe there is any full-proof way of knowing a file's encoding other than guessing an encoding and then trying to decode with it.
The editor might assume, for example, a UTF-8 encoding, a very common encoding capable of encoding any Unicode character. If the file decodes without errors there is nothing else to do. Otherwise, I am sure the editor has a strategy of trying certain other encodings until it succeeds and produces something without a decoding error or finally gives up. In the case of an editor that understands content, even if the file decodes without an error, the editor might additionally check to see if the content is representative of what is implied by the file type.
how does editor know python file's encoding?