encode a string `data to be encoded` to `ascii` encoding,encoded = 'data to be encoded'.encode('ascii')