From my experience with python serial write, I found that the problem was due to the string needing to be converted into a bytearray. To fix this, I modified my code like this:
ser.write("%01#RDD0010000107**\r".encode())
This change resolved the error and allowed me to send the string to the serial port correctly. Always remember to check the data type before sending it out!