java web开发小记,6将int类型的list插入到mysql数据库

首先要明确一点,数据库中没有直接与list对应的数据类型,因此要曲线救国,先转换成string再插入数据库

使用join方法

例子

a = ','.join(['abc','def','ghi'])
print(a)

就能得到一个string 

但是int类型会出点小问题,说int不能用join,因此要先转换成str list

map(str, a)

连起来用就是

 a_str= ' '.join(map(str,a))

然后就是常规的字符串插入

参考:https://blog.csdn.net/chichoxian/article/details/54948875

https://blog.csdn.net/u013810296/article/details/57082163