In computer graphics, there are many ways to represent rotation, such as Euler Angle,Axis Angle,Quaternion,Rotation Matrix. But there are a few convert tools for the rotation representation in Python.
You can just copy the code into your project or install it with pip
pip install git+https://github.com/li-xl/rotationconverter.git
This project uses the functions of Three.js, and refers to the following projects:
https://github.com/gaschler/rotationconverter
https://github.com/Krasjet/quaternion
There are two useful references.