Division of timedelta in Python 2.7 series

I'm addicted to Python 2.7.9 because I can't divide timedelta

To find out how many days or more it was given a time width, we did the following:

test.py


import datetime

oneday = datetime.timedelta(days = 1)
delta = datetime.timedelta(minutes = 3000)
print delta // oneday

Looking at the reference, I thought I could go with this, but an error. TypeError: unsupported operand type(s) for //: 'datetime.timedelta' and 'datetime.timedelta'

It was solved by using the total_seconds method added from 2.7 series.

test.py


import datetime

oneday = datetime.timedelta(days = 1)
delta = datetime.timedelta(minutes = 3000)
print delta.total_seconds() // oneday.total_seconds()

In the 3.x system, it passes from the beginning, so I wonder if division was added from 3.

Recommended Posts

Division of timedelta in Python 2.7 series
Equivalence of objects in Python
Implementation of quicksort in Python
Pixel manipulation of images in Python
MySQL-automatic escape of parameters in python
Handling of JSON files in Python
Implementation of life game in Python
Waveform display of audio in Python
Python Math Series ⓪ Table of Contents
Law of large numbers in python
Implementation of original sorting in Python
Reversible scrambling of integers in Python
Fourier series verification code written in Python
Check the behavior of destructor in Python
(Bad) practice of using this in Python
General Theory of Relativity in Python: Introduction
Output tree structure of files in Python
Comparison of Japanese conversion module in Python3
Summary of various for statements in Python
The result of installing python in Anaconda
[Python] Accelerates loading of time series CSV
Gang of Four (GoF) Patterns in Python
The basics of running NoxPlayer in Python
Bulk replacement of strings in Python arrays
Project Euler # 16 "Sum of Powers" in Python
Basic grammar of Python3 series (list, tuple)
Traffic Safety-kun: Recognition of traffic signs in Python
Summary of built-in methods in Python list
Non-logical operator usage of or in python
In search of the fastest FizzBuzz in Python
Easy introduction of python3 series and OpenCV3
Practical example of Hexagonal Architecture in Python
Project Euler # 17 "Number of Characters" in Python
Double pendulum equation of motion in python
Adding Series to columns in python pandas
Get rid of DICOM images in Python
Status of each Python processing system in 2020
Project Euler # 1 "Multiples of 3 and 5" in Python
Meaning of using DI framework in Python
Python in optimization
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
Meta-analysis in Python
Unittest in python
Epoch in Python
Discord in Python
Sudoku in Python
DCI in Python
quicksort in python
nCr in python
N-Gram in Python
Basics of Python ①
Basics of python ①
Programming in python
Plink in Python
Constant in python
Copy of python
Lifegame in Python.
FizzBuzz in Python