0
Guys I got my script :
import sys
search = sys.argv[1]
ref_arquivo = open('C:/Zabbix/RelatorioErros.txt','r').readlines()[11:]
for line in ref_arquivo:
if search in line:
print(line[30:66],line[66:77],line[92:99],line[100:110])
it works only on UTF-8 files but when running it on a machine windowns when reading Reporterrors.txt does not work because the form of txt is in Unicode what to do ?
Are you sure this is the error? Could post error message here?
– G. Bittencourt
To function
open
has the parameterencoding
that you can define which encoding is used in reading the file; by default it is UTF-8.– Woss
@Woss default is not always UTF-8; of Docs,
In text mode, if encoding is not specified the encoding used is platform dependent: locale.getpreferredencoding(False) is called to get the current locale encoding.
. That assumption that it’s UTF-8 by default has bit me too!– Pedro von Hertwig Batista
@Pedrovonhertwigbatista Well remembered.
– Woss