python – subprocess.PIPE not working correctly for me

I am testing the python socket and now I am trying to execute commands on the client PC, the problem is that when I execute commands like "dir", it doesn't give me not output correctly and i don't know how to make it look exactly like the console when i run it on my pc.

Here is the code:

cmd=subprocess.Popen('dir',shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE,stdin=subprocess.PIPE)
out = cmd.stdout.read() + cmd.stderr.read()
print(out)

and it gives me a strange result where " n" or " x" doesn't work and I don't know how to make it look beautiful

>>>b' El volumen de la unidad C no tiene etiqueta.rn El nxa3mero de serie del volumen es: DE4B-C86Arnrn Directorio de C:\Users\Administrador\AppData\Local\Programs\Python\Python36rnrn01/05/2020  23:19              .rn01/05/2020  23:19              ..rn23/04/2020  20:28              DLLsrn23/04/2020  20:28              Docrn03/05/2020  22:44              includern02/05/2020  13:51              Librn23/04/2020  20:28              libsrn28/03/2018  17:07            30.340 LICENSE.txtrn28/03/2018  17:07           392.371 NEWS.txtrn28/03/2018  17:04           100.504 python.exern28/03/2018  17:01            58.520 python3.dllrn28/03/2018  17:00         3.610.776 python36.dllrn28/03/2018  17:04            98.968 pythonw.exern03/05/2020  22:44              Scriptsrn23/04/2020  20:28              tclrn23/04/2020  20:28              Toolsrn09/06/2016  22:53            87.888 vcruntime140.dllrn               7 archivos      4.379.367 bytesrn              10 dirs  239.329.681.408 bytes libresrn'