19 
 
        
      
      แปลงไบต์เป็นสตริง
      
  ฉันใช้รหัสนี้เพื่อรับเอาต์พุตมาตรฐานจากโปรแกรมภายนอก: >>> from subprocess import * >>> command_stdout = Popen(['ls', '-l'], stdout=PIPE).communicate()[0] วิธีการสื่อสาร () วิธีการส่งกลับอาร์เรย์ไบต์: >>> command_stdout b'total 0\n-rw-rw-r-- 1 thomas thomas 0 Mar 3 07:03 file1\n-rw-rw-r-- 1 thomas thomas 0 Mar 3 07:03 file2\n' อย่างไรก็ตามฉันต้องการทำงานกับผลลัพธ์เป็นสตริง Python ปกติ เพื่อให้ฉันสามารถพิมพ์ได้เช่นนี้ >>> print(command_stdout) -rw-rw-r-- 1 thomas thomas 0 Mar 3 07:03 file1 …
      
        
          
                   2307
                
        
        
          
                  
                    python 
                  
                    string 
                  
                    python-3.x