标签: python list
说我有一个列表如:
cols = ['price', 'cost', 'buy', 'sell']
现在,我想遍历cols并在每个项目后创建列表名称,即:
cols
price = [] cost = [] buy = [] sell = []
尝试:
for col in cols: cols[col] = []
但这显然失败了。
哪种方法可以实现这一目标?感谢