Jan-10-2018, 10:11 AM
I have a problem with my code
response = requests.get("http://www.testecliente.com.br/ApiTeste/GetDadosCartaoCliente?CL_COD=1" )
retorno = response.content
retorno = retorno.decode("utf-8")
json_data = json.loads(retorno)
CL_NOME = json_data['CL_NOME']
print ("NOME=" + CL_NOME)
When I try to run the following error occurs :
CL_NOME = json_data['CL_NOME']
TypeError : string indices must be integers
if I send print json_data appears:
{"CC_COD":16,"CL_COD":40,"CC_NUMERO_CARTAO":"68453217628884","CC_BANDEIRA":"visa","CC_VALIDADE":"09/21","CC_COD_SEGURANCA":"188","CC_FUNCAO":"C","CC_PRINCIPAL":"S","CL_NOME":"Alexandre Luiz"}
if I print the type the result is:
print (type(json_data))
result --> <class 'str'>
Can someone help me ?
response = requests.get("http://www.testecliente.com.br/ApiTeste/GetDadosCartaoCliente?CL_COD=1" )
retorno = response.content
retorno = retorno.decode("utf-8")
json_data = json.loads(retorno)
CL_NOME = json_data['CL_NOME']
print ("NOME=" + CL_NOME)
When I try to run the following error occurs :
CL_NOME = json_data['CL_NOME']
TypeError : string indices must be integers
if I send print json_data appears:
{"CC_COD":16,"CL_COD":40,"CC_NUMERO_CARTAO":"68453217628884","CC_BANDEIRA":"visa","CC_VALIDADE":"09/21","CC_COD_SEGURANCA":"188","CC_FUNCAO":"C","CC_PRINCIPAL":"S","CL_NOME":"Alexandre Luiz"}
if I print the type the result is:
print (type(json_data))
result --> <class 'str'>
Can someone help me ?