你的程序的第8行,
is_valid == False
应该是
is_valid = False ,
is_valid = False
自从 == 是一个比较运算符(比较两个值是否相等),您要查找的是 = 赋值操作(给一个事物赋值)。
==
=