最佳答案
Python 保留字和内置程序的列表在库中是否可用:
from x.y import reserved_words_and_builtins
if x in reserved_words_and_builtins:
x += '_'