Command to trim excess or fillet?

I figured out how to select all of these in python but is there a way to get rid of the excess lines at the corners?