If I try to use a magic comment like #coding=utf-8 on top of a file, here's what happens:
Traceback (most recent call last):
File <string>, line 0
SyntaxError: encoding declaration in Unicode string
I really haven't done anything wrong. Here is the code:
#coding=utf-8
string = raw_input()
chars = {}
for i in string:
if i in chars:
chars[i] += 1
else:
chars[i] = 0
print chars
I use repl.it.
encoding, notcoding.coding!decoding, orflubcoding, or justcoding. The regex used doesn't care. See What's the difference between 'coding=utf8' and '-*- coding: utf-8 -*-'?