convert list to string to insert into my sql in one row in python scrapy

后端 未结 3 1733
离开以前
离开以前 2020-12-04 00:53

I want to convert a list object into a string and insert this string as one row in mysql database. Can someone please provide a solution to this. My code looks like this:

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-04 01:34

    If you want to convert a list into a string you can use join.

    >>> myl = ['a','b','c']
    >>> "".join(myl)
    'abc'
    

    you can use any delimiter of your choice in between the quotes

    >>> myl = ['a','b','c']
    >>> ",".join(myl)
    'a,b,c'
    

提交回复
热议问题