python list 内嵌列 表转为一维列表
https://blog.csdn.net/u010652755/article/details/105549848?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522160188046619195188364090%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=160188046619195188364090&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2allfirst_rank_ecpm_v3~pc_rank_v2-1-105549848.first_rank_ecpm_v3_pc_rank_v2&utm_term=%E5%86%85%E5%B5%8C%E5%88%97%E8%A1%A8%E8%BD%AC%E5%88%97%E8%A1%A8&spm=1018.2118.3001.4187
可以展开任意维的列表, 使用匿名函数 lambda
func = lambda x: [y for l in x for y in func(l)] if type(x) is list else [x]
a = [[1,2,3], [4,5,6], [7], [8,9], ‘c’]
result = func(a)
python将一维列表转换为多维列表(numpy+reshape)
https://blog.csdn.net/qq_28626909/article/details/81162560?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase
python 纯数字list转化为字符串
在python中,如果将字符串类型的list转化为一个字符串
用
s=[“one”,“two”,“three”]
““join(s)就可以达到目的,而用
纯数字list
s=[1,223,23]
print(”,”.join(s))
TypeError: sequence item 0: expected str instance, int found
会出错,这样就得把list中的每个转为字符,如下:
s=[1,223,23]
print(",".join(str(i) for i in s))
https://blog.csdn.net/chengyq116/article/details/89918640
https://blog.csdn.net/u013724573/article/details/72920924
https://blog.csdn.net/qq_39026556/article/details/82716207?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase