python – namedtuple声明缩进
发布时间:2020-12-20 11:04:59 所属栏目:Python 来源:网络整理
导读:我有以下命名的元组: from collections import namedtupleProduct = namedtuple( 'Product','product_symbol entity unique_id as_of_date company_name followers linkedin_employees linkedin industry date_added date_updated description website sect
我有以下命名的元组:
from collections import namedtuple Product = namedtuple( 'Product','product_symbol entity unique_id as_of_date company_name followers linkedin_employees linkedin industry date_added date_updated description website sector product_industry' ) 声明它的最佳方法是什么,所以它不超过80行的Python行限制? 解决方法
我提出了一个PEP-8兼容版本,它将您的属性声明为列表.
name = 'Product' attrs = [ 'product_symbol','entity','unique_id',... ] Product = namedtuple(name,attrs) 将尾随逗号添加到attrs,this makes it easy when doing diff comparisons. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |