1

例子:

class Geeks:
     def __init__(self):
          self._age = 0
          self._height = 0
          self._weight = 0
       
     # using property decorator
     # a getter function
     @property
     def age(self):
         return self._age
       
     # a setter function
     @age.setter
     def age(self, a):
         self._age = a

有没有办法在 VS Code 中为 Python 自动生成这样的 getter 和 setter?

4

0 回答 0