Python中对象作为元素组成列表问题,[obj]代表什么含义?
PHPz
PHPz 2017-04-18 09:23:17
0
1
529

1.下面这行代码中,[obj]是对象列表吗?没有读懂下面代码的这一处。
从运行上看,[obj]的确是可迭代的iterable。

在run.py中

obj=TR_OBJ(seq,labels,name=sys.argv[1]) 
tr_obj_list=[obj]

for o in tr_obj_list:    #    obj仅仅是一个对象吗?
    do_something(o.seq)

关于TR_OBJ的类定义

class TR_OBJ:
    ''' define a trainable object, a TR_OBJ object cositst of: 
        self.seq    # the list of symbols || vectors
        self.labels    # the list of the labels
        self.name    # the object name
        ……
    '''

    def __init__(self, seq, labels=[], f=[], b=[], eMat=[], scale=[], p=None, name=None):
        self.seq = seq          # the list of symbols || vectors
        self.labels = labels    # the list of the labels
        self.name = name        # the object name
        ……
PHPz
PHPz

学习是最好的投资!

membalas semua(1)
大家讲道理

Saya tidak begitu memahami soalan anda

Tetapi [obj] hanyalah senarai, jadi sudah tentu ia boleh diulang!


Soalan yang saya jawab: Python-QA

Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan