This is strange. Run the code and it works fine on local server but when uploading it to app engine it doesn't work at all and gets the error:
if int(totaltime[0:2]) == 23 and int(totaltime[3:5]) >= 45:
ValueError: invalid literal for int() with base 10: ', '
Here is the code that is triggering it:
if int(totaltime[0:2]) == 23 and int(totaltime[3:5]) >= 45:
ta = "yes"
else:
ta = "no"
totaltime is 23:27:35 so int(totaltime[0:2]) gets 23 and (totaltime[3:5]) gets 27. I don't understand why this doesn't work online but works fine local.
The exception says that your input data contains a comma, so your expectation of totaltime
being 23:27:35
is clearly violated.
Try outputting repr(totaltime[0:2])
and repr(totaltime[3:5])
on Appengine.
Also, you can split the if-statement into two lines like so:
if (int(totaltime[0:2]) == 23 and
int(totaltime[3:5]) >= 45):
That will let you see which of the calls to int()
triggers the ValueError
, making debugging a bit easier.
Also be aware that date strings (both from time
and datetime
honor the locale settings, which may explain the discrepancy between your development system and AppEngine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.