成功解决local variable 'str' referenced before assignment

NoSuchKey