热线电话:13121318867

登录
2019-04-29 阅读量: 370
python如何向散列添加属性

Perl中的属性存储为散列引用中的键值对。此外,向代码添加一些属性。

package Area;

sub new

{

my $class = shift;

my $self =

{

length => 2, # storing length

width => 3, # storing width

};

return bless $self, $class;

}

1;

上面的代码(AreaClass)有两个属性:lengthwidth

0.0000
2
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子