Is it possible to remove all single quotes from a list of strings in python?

user7431098

I have 3 lists, yearlist, monthlist and daylist. I'm trying to combine all 3 and add strings between them.

for i in range(0,j):
    singledate = 'datetime(year=' + yearlist[i] + ', month=' + monthlist[i] + ', day=' + daylist[i] + ')'
    datelist.append(singledate)
print singledate
print datelist

This prints singledate as datetime(year=2009, month=01, day=15), but datelist as ['datetime(year=2009, month=02, day=14)', 'datetime(year=2009, month=01, day=15)']

Is it possible to remove all " ' " in datelist? Thanks

Rahul K P

If you are looking for datetime, You don't want to use string, Try something like this,

In [12]: import datetime
In [13]: datelist = [datetime.datetime(yearlist[i],monthlist[i],daylist[i]) for i in range(0,j)]

Result

[datetime.datetime(2009, 1, 14, 0, 0), datetime.datetime(2009, 2, 15, 0, 0)]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Remove Square Brackets and Double quotes from list of strings in Python

How to remove double quotes from strings in a list in python?

Scala - Remove all elements in a list/map of strings from a single String

Remove prefix quotes from a list of strings

How to remove double quotes from list of strings?

Remove quotes from a list of strings (that are supposed to be tuples)

Remove quotes from list - Python

Generate all possible sequential strings from list using Python 3

How to remove all strings from a list of tuples python

How to replace single quotes from a list in python

Python Remove List of Strings from List of Strings

Remove Brackets and Single quotes from list loaded from CSV file

Remove additional quotes from python list

Remove quotes from list of dictionaries in python

Remove quotes from a list of tuples in python

How to remove quotes from a list in Python?

Remove single quotes in list in pyspark

Remove outside double quotes from list of jinja strings

Read a list of strings from text file and remove the extra quotes

Remove extra escaped double quotes from list of Clojure strings

How to remove single quotes from imported csv file into a list?

Python list of lists remove single quotes on one value

Remove all escape sequences from list of strings

Python - Remove all sub-strings not in list

How to remove single quotes in python

remove sublist from a single list of list python

How can I remove single quotes from a column using python

Remove all the '#' from a list in python

Getting all possible strings from subsequences in python