Fastest way to insert these dashes in python string?

前端 未结 8 1478
失恋的感觉
失恋的感觉 2021-02-13 16:34

So I know Python strings are immutable, but I have a string:

c[\'date\'] = \"20110104\"

Which I would like to convert to

c[\'da         


        
8条回答
  •  闹比i
    闹比i (楼主)
    2021-02-13 17:10

    Add hyphen to a series of strings to datetime

    import datetime
    for i in range (0,len(c.date)):
      c.date[i] = datetime.datetime.strptime(c.date[i],'%Y%m%d').date().isoformat()
    

提交回复
热议问题