Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

strftime python multiple formats

from datetime import datetime

def try_parsing_date(text):
    for fmt in ('%Y-%m-%d', '%d.%m.%Y', '%d/%m/%Y'):
        try:
            return datetime.strptime(text, fmt)
        except ValueError:
            pass
    raise ValueError('no valid date format found')
Comment

PREVIOUS NEXT
Code Example
Python :: how to print keys and values of dictionary together in python? 
Python :: if name == main 
Python :: capitalize first letter of each word python 
Python :: python last 3 list elements 
Python :: spark to pandas 
Python :: rounding values in pandas dataframe 
Python :: jupyter dark theme vampire 
Python :: set permissions role discord.py 
Python :: check if string contains python 
Python :: oversampling using smote 
Python :: python return value from single cell dataframe 
Python :: python combine two lists into matrix 
Python :: python fractions 
Python :: use django taggit in template 
Python :: get current domain name django 
Python :: python telegram bot 
Python :: tweepy aut code 
Python :: python list add first 
Python :: reverse python 
Python :: generate random integers python 
Python :: python str contains word 
Python :: pandas eliminar filas de un dataframe con una condicion 
Python :: how to raise the exception in __exit__ python 
Python :: next() python 
Python :: keras maxpooling1d 
Python :: checksum python 
Python :: combine two columns pandas 
Python :: python regex get word after string 
Python :: sendgrid send email to multiple recipients python 
Python :: progress bar python text 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =