Find all files with the extensions .php or .py in the src directory and its subdirectories, and execute the command sed -i 's/\s*$//' on each of them.
find ./src -maxdepth 2 \( -name '*.php' -o -name '*.py' \) -exec sed -i 's/\s*$//' {} +