补充程序
本帖最后由 ooooosh 于 2020-5-27 17:04 编辑class Bg:
( )#定义公共属性“ag”并赋初值1
def __init__(self,nj):
self.nj=nj
x1=Bg('20190001')
x2=Bg('20190002')
x1.ag=3
( )=int(input()) #修改类的“ag”属性值
print(x1.ag,x2.ag) 这样即可吧:
class Bg:
ag = 1#定义公共属性“ag”并赋初值1
def __init__(self,nj):
self.nj=nj
x1=Bg('20190001')
x2=Bg('20190002')
x1.ag=3
Bg.ag=int(input()) #修改类的“ag”属性值
print(x1.ag,x2.ag) class Bg:
ag = 1#定义公共属性“ag”并赋初值1
def __init__(self,nj):
self.nj=nj
x1=Bg('20190001')
x2=Bg('20190002')
x1.ag=3
x2.ag=int(input()) #修改类的“ag”属性值
print(x1.ag,x2.ag)
页:
[1]