Files
Python/Code/Python10Code/com/twowater/mtest3.py
2017-09-11 09:44:22 +08:00

17 lines
364 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
class User(object):
name=''
def __setattr__(self, name, value):
# 每一次属性赋值时, __setattr__都会被调用因此不断调用自身导致无限递归了
# 会造成程序奔溃
self.name = value
if __name__ == '__main__':
user = User()
user.name='两点水'