Easy way to convert a unicode list to a list containing python strings?

前端 未结 9 2048
臣服心动
臣服心动 2020-12-23 16:42

Template of the list is:

EmployeeList =  [u\'\', u\'\', u\'\', u\'\']

I would like to con

9条回答
  •  时光说笑
    2020-12-23 17:30

    Just json.dumps will fix the problem

    json.dumps function actually converts all the unicode literals to string literals and it will be easy for us to load the data either in json file or csv file.

    sample code:

    import json
    EmployeeList =  [u'1001', u'Karick', u'14-12-2020', u'1$']
    result_list = json.dumps(EmployeeList)
    print result_list
    

    output: ["1001", "Karick", "14-12-2020", "1$"]

提交回复
热议问题