有nonetype的list怎么转str

  统计/机器学习 Python    浏览次数:2961        分享
0


stri=" ".join(i)
TypeError: sequence item 0: expected str instance, NoneType found
 

constant007   2019-06-18 18:50



   1个回答 
0

NoneType不能直接进行join

你可以自动跳过None

" ".join([x for x in i if x is not None])

或者把None替换成“空”

" ".join(["空" if x is None else x for x in i])
SofaSofa数据科学社区DS面试题库 DS面经

何立诚   2019-06-18 22:26



  相关讨论

re 不能在list 或者dataframe查找?

怎么把字符串形式的list转成真的list

返回python list里各个元素的大小排序?

python如何把list中的item作为变量的后缀 从而产生for中的动态变量名

python字符串形式的数值转成单个整数的list,怎么操作?

python报错:'list' object has no attribute 'Angle',求教

python怎么对list中的元素做连乘?

怎么把pandas dataframe中的一列转成一个list?

如何把一个pandas的dataframe的columns转换成list

python里怎么把中文字符串转化为成list

  随便看看

返回DataFrame或者array的行数

什么是混淆矩阵(confusion matrix)

logloss的取值范围是多少?一般好的分类器能达到多少?

Data Application Lab怎么样?

如果样本不是正态分布,还能用t-test或者z-test吗?