I’m having a Typeerror: '_io.Textiowrapper' Object is not subscriptable

Asked

Viewed 16 times

-3

import json

def abrir():
  with open('estoque.txt', 'w+') as nome:
    nomez = str (input('Digite Nome do Produto: '))
    Quant = int (input('Digite Quantidade do produto: '))
    PC = float (input('Digite o Preço de Custo: '))
    PV =  float (input('Digite o Preço de Venda: '))
    
  
    L = [f'{nomez},{Quant}, {PC}, {PV}']
    json.dumps(L)
    nome.write(f'{L}')
def ler(nome):

    with open('estoque.txt', 'rt') as nome:
        print(nome.read())


def alterar(nome):
    with open('estoque.txt', 'r+') as nome:
     print(nome.readlines())
     print(nome[1]) 

#I want to show only one item inside the file not all

resp = int (input('Digita ae: '))
if resp == 1:
  ler(ler)
elif resp == 2:
  abrir()
elif resp == 3:
  alterar(alterar)
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.