如何在 Python 中声明重音变量

How to declare accented variables in Python

我需要为 Python 的学生编写一些基本脚本,例如:

#!/usr/bin/python
# -*- coding: utf-8 -*-

mia_età = 31
print mia_età

但显然我不能在声明变量时使用重音字符。有什么办法吗?

("mia_età" 在意大利语中的意思是 "my_age" 我想避免他们在学习 Python 时用母语写语法错误 Python)

Python1和2只支持ASCII字母数字字符和_identifiers.

Python 3 支持所有 Unicode 字母和 identifiers.

中的某些标记
#!/usr/bin/python3
# -*- coding: utf-8 -*-
mia_età = 31
print(mia_età)

根据 NFKC,标识符是 normalized,因此您可以随意编写 U+0061 LATIN SMALL LETTER A 后跟 U+0301 COMBINING ACUTE ACCENT,或 U+00E1 LATIN SMALL LETTER A WITH ACUTE。