Python code deal with integration method