0

What is the best pythonic way to covert, a string as '11-2020' to 'NOV-2020' in Python.

I tried below code :

print(datetime.datetime.strptime(date, '%m-%Y').strftime('%b-%Y')) 

But getting output like : Nov-2020 (I want Nov to be in caps)

1
  • use datetime.datetime.strptime(date, '%m-%Y').strftime('%b-%Y').upper() Commented Jan 18, 2021 at 7:06

1 Answer 1

1
print(datetime.datetime.strptime(date, '%m-%Y').strftime('%b-%Y').upper()) #NOV-2020 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.