Python strftime- date without leading 0?

0 votes
While using Python strftime, is there any way to remove the first 0 of the date if it's before the 10th, ie.  01 is 1? Can't find a way for that.
Dec 31, 2018 in Python by ana1504.k
• 7,870 points
40 views

1 answer to this question.

0 votes
If you add a hyphen between the % and the letter, you can remove the leading zero.

For example %Y/%-m/%-d.

This only works on Unix (Linux, OS X), not Windows.  On Windows, you would use #, e.g. %Y/%#m/%#d.
answered Dec 31, 2018 by SDeb
• 13,180 points

Related Questions In Python

+2 votes
11 answers
0 votes
1 answer

How to exit from Python without traceback?

shutil has many methods you can use. One ...READ MORE

answered May 10, 2018 in Python by charlie_brown
• 7,720 points
119 views
0 votes
1 answer

How to exit from Python without traceback?

Perhaps you're trying to catch all exceptions ...READ MORE

answered Jul 31, 2018 in Python by Priyaj
• 56,900 points
752 views
+3 votes
2 answers

how to print array integer without [] bracket in python like result = 1,2,3,4,5

Hey @abhijmr.143, you can print array integers ...READ MORE

answered Aug 4, 2018 in Python by Omkar
• 67,660 points

edited Aug 8, 2018 by Omkar 1,111 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 328 views
0 votes
1 answer

How to exit from Python without traceback?

You are presumably encountering an exception and ...READ MORE

answered Oct 9, 2018 in Python by SDeb
• 13,180 points
92 views
0 votes
1 answer

Python sort() function arguments

Both sort and sorted have three keyword arguments: cmp, key and reverse. L.sort(cmp=None, key=None, reverse=False) -- ...READ MORE

answered Oct 8, 2018 in Python by SDeb
• 13,180 points
306 views