[Tutor] Thanks for your review
Alan Gauld
learn2program at gmail.com
Tue Mar 26 21:09:46 EDT 2024
Always reply-All when respoding to the list. Otherwise it only goes
to the individual and you lose the benefit of the "hive mind" on
the list. (I've CCd the list on this reply)
On 26/03/2024 16:42, Jonathan Wilson wrote:
> main(sys.argv[1], sys.argv[2])
>
> * File "C:\Users\918856164\Desktop\SFSU\UpdateDBFromConsole.py", line
> 61, in main*
>
> * newDBFileName = date.today().strftime("%y.%-m.%-d") + ' ' +
> dbFileName*
>
> *ValueError: Invalid format string*
That's correct, the format string is not a valid strftime format.
I'm not certain what format you want but I suspect it might be:
newDBFileName = date.today().strftime("%y.%m.%d") + ' ' + dbFileName
Which would output something like:
2024.03.26 SomeFilename.db
> newDBFileName = today.strftime("%m%d ")
>
> Here is some actual code:
>>>> d = dt.datetime(2020,6,18)
>>>> d.strftime("{} {} ").format(d.day, d.month)
> '18 6 '
>>>> d.strftime("%d %m ")
> '18 06 '
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list