LIST = ['1','2','3']
a = '-'.join(LIST)
print(a)
import re
arr = ['猪肉概念股', '牛肉概念股', '特斯拉概念股']
result = list(map(lambda x: re.sub('概念股', '', x),arr))
print(result)
# 遍历list
my_list = [1, 2, 3, 4, 5]
for ele in my_list:
print('ele =', ele)
ele = 1
ele = 2
ele = 3
ele = 4
ele = 5
# 遍历dict
my_dic = {'python教程':"http://c.biancheng.net/python/",\
'shell教程':"http://c.biancheng.net/shell/",\
'java教程':"http://c.biancheng.net/java/"}
for ele in my_dic.items():
print('ele =', ele)
ele = ('python教程', 'http://c.biancheng.net/python/')
ele = ('shell教程', 'http://c.biancheng.net/shell/')
ele = ('java教程', 'http://c.biancheng.net/java/')
# enumerate 遍历
seq = ['one', 'two', 'three']
for i, element in enumerate(seq):
print (i, element)
columns = [
'序号', '股票代码', '股票名称', '价格', '涨幅', '成交额', '总市值',
'PE', 'PE温度', 'PB', 'PB温度', '5年平均股息率', '股息率',
'静态股息率', '波动率', '最新年报ROE', '5年平均ROE', '5年营收复合增长', '5年利润复合增长', '5年现金流复合增长', '5年分红率复合增长', '净利同比增长', '有息负债率', '股票质押比例', '行业', '自选'
]
print(len(columns))
td = [
'1', '002110', '三钢闽光 ', '5.250', '-0.38%', '1568.07', '128.71', '7.543',
'55.13', '0.595', '0.68', '14.019%', '15.467%', '8.495%', '会员', '18.44%',
'28.00%', '34.76%', '33.84%', '-0.33%', '11.04%', '-83.26%', '28.73%',
'会员', '长材'
]
print(len(td))
test_list = ['1','2','3','4','5','6','7','8','9','10']
n=3
output=[test_list[i:i + n] for i in range(0, len(test_list), n)]
print(output)
[['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9'], ['10']]