Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid format string in example code #126

Open
tkwon opened this issue Dec 18, 2015 · 4 comments
Open

Invalid format string in example code #126

tkwon opened this issue Dec 18, 2015 · 4 comments

Comments

@tkwon
Copy link

tkwon commented Dec 18, 2015

Line 69 of example/app/conf.py reads:

    'x_fp_timestamp': datetime.datetime.now().strftime('%s'),

This throws an error complaining of invalid format string. There doesn't appear to be %s available for strftime.

@theju
Copy link
Contributor

theju commented Dec 18, 2015

Which version of Python are you using?

On Python 2.7.10 and Python 3.4.3 on Linux, I can't reproduce the problem.

Python 2.7.10 (default, Sep  8 2015, 17:20:17) 
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> datetime.datetime.now().strftime("%s")
'1450438250'
>>>
[theju@localhost]~/% python3.4
Python 3.4.3 (default, Jun 29 2015, 12:16:01) 
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> datetime.datetime.now().strftime('%s')
'1450438269'
>>>

@theju
Copy link
Contributor

theju commented Dec 18, 2015

Or best is if you can enclose the exact error.

@tkwon
Copy link
Author

tkwon commented Dec 18, 2015

I'm using Python 2.7.10 and django 1.8 and 1.8.4 on Windows.

Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)

import datetime
datetime.datetime.now().strftime('%s')
Traceback (most recent call last):
File "", line 1, in
ValueError: Invalid format string

@bzd111
Copy link

bzd111 commented Apr 18, 2017

I have same problem on windows,but on linux no problem with same code

Windows:
In [75]: datetime.now().strftime('%s')
ValueError Traceback (most recent call last)
in ()
----> 1 datetime.now().strftime('%s')

ValueError: Invalid format string
Linux:
In [14]: datetime.now().strftime('%s')
Out[14]: '1492505828'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants