A:
All the problems have to be solved at a lower level than the language which is more or less garbage on it's own (java for example). Since this means you have to change the languages code base, you might as well not use it and code it in C++ instead. The language doesn't matter, as long as it's fast enough and you don't need the added flexibility of a language. C++ would likely be better.
Q:
How to convert a string "to" datetime?
I have a string, e.g. "2007-05-01", that I want to convert to a datetime object.
I was told to try the following:
x = datetime.strptime(x,'%Y-%m-%d')
However, that doesn't work, and I get the following error:
AttributeError: strptime() argument 1 must be str, not datetime.datetime
The reason I think this is happening is that the string in x is not in the format "YYYY-MM-DD" but "YYYY-MM-DD-hh-mm", for instance "2007-05-01-15-47".
I know that it is an incomplete datetime because if I convert it to an actual datetime object with.datetime.datetime, it does what I want it to.
Is there any easy way to convert the string to a datetime object? I'm using Python 2.7.
A:
You have misunderstood what the strptime function does.
strptime(s,format)
Returns a datetime object from a string in a format string.
In your example you have passed an argument of type datetime.datetime not string.
A:
The error is pretty obvious. strptime() takes an argument of type string and not datetime.datetime.
If your date string is in the format you've provided, you can do
from datetime import datetime
datetime.strptime('2007-05-01-15-47', '%Y-%m-%d-%H-%M')
This returns a datetime object, and you can then use normal methods on the object such as.date(),.time() etc.
. We are ready for a new generation and a new leaf. 01e38acffe
Razer warlock free xbox games.sirbok.net// { dg-do compile { target c++11 } }
// Copyright (C) 2013-2020 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// .
#include
template
void
print_out(Result &&__out)
{
for (auto __i = 0; __i func = [](int)
{ return 0; };
int a[3] = { 0, 0, 0 };
int& r = a[0];
print_out(func);
}
// libstdc++/4691
void
test02()
{
int a[3] = { 0, 0, 0 };
int& r = a[0];
print_out(std::plus());
}
int
main()
{
test01();
test02();
}
Download the MP3 | Watch the Video
The Harvey Weinstein imbroglio, lawsuits, elections, Jeff Bezos, the Four Horsemen of the Apocalypse, a dead 80’s
Related links:
Comments