def stringToLek(red):
    lek = {}
    deo = red.strip().split("|")
    lek["ser_br"] = int(deo[0])
    lek["fab_naziv"] = deo[1]
    lek["gen_naziv"] = deo[2]
    lek["kol_leka"] = int(deo[3])
    lek["c_leka"] = float(deo[4])
    return lek
def  lekToString(lek):
    return '|'.join([lek['ser_br'], lek['fab_naziv'], lek['gen_naziv'], lek['c_leka'], lek['kol_leka']])

.................................................................................
TypeError: sequence item 0: expected str instance, int found

最佳答案

def  lekToString(lek):
return '|'.join([str(lek['ser_br']), str(lek['fab_naziv']), str(lek['gen_naziv']), str(lek['c_leka']), str(lek['kol_leka'])])

关于python - TypeError:序列项0:预期的str实例,找到的int,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27610470/

10-12 18:20