欢迎来到代码驿站!

Python代码

当前位置:首页 > 软件编程 > Python代码

Python实现结构体代码实例

时间:2021-03-12 09:54:14|栏目:Python代码|点击:

这篇文章主要介绍了Python实现结构体代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

# python 使用类创建结构体
class Myclass(object):
  class Struct(object):
    def __init__(self, name, age, job):
      self.name = name
      self.age = age
      self.job = job

  def make_struct(self, name, age, job):
    return self.Struct(name, age, job)

myclass = Myclass()
test1 = myclass.make_struct('xsk', '22', 'abc')
test2 = myclass.make_struct('mtt', '23', 'def')

print test1.name
print test1.age
print test1.job
print test2.name
print test2.age
print test2.job

上一篇:pytorch模型预测结果与ndarray互转方式

栏    目:Python代码

下一篇:Django框架模板文件使用及模板文件加载顺序分析

本文标题:Python实现结构体代码实例

本文地址:http://www.codeinn.net/misctech/79149.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有