Why is my Python serial write command giving a TypeError?

Ah, yes, that’s one way to go about it. What I usually do is use bytes() to convert the string into a byte object before writing it. Here’s an example:

ser.write(bytes("%01#RDD0010000107**\r", 'utf-8'))

In fact, this method can be especially useful when you’re working with specific encodings like UTF-8. I’ve found it to be very reliable when dealing with python serial write issues, especially when the encoding matters.