How to save a list as a .csv file with python with new lines?

后端 未结 3 1586
孤独总比滥情好
孤独总比滥情好 2021-02-02 10:24

I would like to save a python list in a .csv file, for example I have a list like this:

[\'hello\',\'how\',\'are\',\'you\']

I woul

3条回答
  •  一向
    一向 (楼主)
    2021-02-02 10:59

    use pandas to_csv (http://pandas.pydata.org/pandas-docs/dev/generated/pandas.DataFrame.to_csv.html)

    >>> import pandas as pd
    >>> df = pd.DataFrame(some_list, columns=["colummn"])
    >>> df.to_csv('list.csv', index=False)
    

提交回复
热议问题