【发布时间】:2021-05-30 20:51:42
【问题描述】:
正如您从下面的代码中看到的,我想从 Owner 类 change_company_name 函数中更改公司类名称变量 我怎样才能做到这一点 ? 谢谢
class Company:
name = "A Company name"
def __init__(self,num_of_employees,found_year):
self.num_of_employees = num_of_employees
self.found_year = found_year
class Owner:
Company.name = "I know that here is changing the Company name"
def change_company_name(self): ### I want to change Company name from function in another Class
Company.name = "Another Company Name"
print(Company.name)
【问题讨论】:
标签: python python-3.x class python-class