I'm having a problem with python \ b (backspace), instead of deleting the previous character, it generates a "•" as shown below:
Thefollowingisthelineofcodethatgeneratesthisreturn:
#-*-coding:utf-8-*-importpyodbcimportplatformimportjson#------------------------------------------------------#local_arq=open("C:\Zabbix\prm2.txt", 'r') #Caminho do arquivo cujo encontra-se aa instancias
leitura = local_arq.readlines() #leitura das linhas do arquivo
varhost = platform.node()
x = 0 #var usada para separar os dados recebidos do TXT && Alterar o valor do hostname
y = 0
with open("test3.txt","w") as arq:
print('{"data": [')
for li in leitura:
count = li.split('--') #count = contador ele recebe os dados do TXT e separa eles onde tem o -
count[x].replace(" ", "") #Remove todos os espaços
for li2 in count:
hostname = varhost + '\' + count[x]
con = pyodbc.connect("DRIVER={SQL Server};server="+hostname+";uid=sa;pwd=Ww1234567.")
query = con.cursor()
query.execute("SELECT name FROM SYSDATABASES")
for row in query:
#print(row)
print('{"{#INSTANCENAME}": "%s","{#DBNAME}": "%s"},' %(count[x], row[y]))
lol = ('{"{#INSTANCENAME}": "%s","{#DBNAME}": "%s"},' %(count[x], row[y]))
x = x + 1
print(lol + '\b]}')
y = y + 1
In this case, I'm using \ b to delete that comma.
Thank you in advance!
NOTE: Python 3.7 version