1

I'm trying to get the files and directories of the current working directory with

info = subprocess.run("dir", shell=True, capture_output=True)
print(info.stdout)

but I have files with é and they are printed as , instead...

I also have a problem with the free bytes, I get that :

49ÿ372ÿ921ÿ856 octets libres

I tried to decode it but I get an error saying AttributeError: 'std_output' object has no attribute 'decode'

So apparently it's already decoded.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343

1 Answers1

0

The accent aigu "é" is actually two characters when put in a UTF string. It's "´ – e", so this is the expected behavior.

Also, you don't need subprocess for listing a directory. You could just do:

import os
os.listdir(".")
Iman Akbari
  • 2,167
  • 26
  • 31