1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

python3 datetime replaceで20分もはまった

Posted at

悩み

from datetime import datetime as dt
now = dt.now()
print('{0:%-M}'.format(now))
now.replace(minute=8)
print('{0:%-M}'.format(now))

42
8
と出力されてほしかったが、
42
42
と出力されてしまった。

答え

from datetime import datetime as dt
now = dt.now()
print('{0:%-M}'.format(now))
now = now.replace(minute=8)
print('{0:%-M}'.format(now))

くだらなかった。。。

1
1
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?