Alan
Alan

Reputation: 253

how do I show the correct text in the powershell console

My process1.txt is get from ps > process1.txt in windows powershell it is like this

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName                                                  
-------  ------    -----      -----     ------     --  -- -----------                                                                                                     
    167      12     2044       8024       0.02  14640   1 acrotray                                                     
    448      29    46584      33768       0.30  14692   1 acwebbrowser

I use ipython3 in win10

In [12]: f = open('process1.txt',encoding = 'unicode_escape')

In [13]: line = f.readlines()

I want to show the third line like

167      12     2044       8024       0.02  14640   1 acrotray    

but when I type in line[3] is show like this

In [15]: line[3]
Out[15]: '\x00\n'

and mysystem is utf-8 system how do I show the correct line ?

Upvotes: 1

Views: 31

Answers (1)

Alan
Alan

Reputation: 253

I used ConEmu and regenerated the file in the ConEmu console

tasklist > process3.txt

and get this

In [1]: f = open('process3.txt')

In [2]: line = f.readlines()

In [3]: line[3]
Out[3]: 'System Idle Process              0 Services                   0          8 K\n'

Upvotes: 1

Related Questions