„The Movie Database“ palaikymas

Hello,

I'm trying desperately to display json code in python3. How to convert the variable 'data' in json, to not have a 'print (data)' with a big block of text?

cordially

3 atsakė (on page 1 iš 1)

Jump to last post

Hi there,

I am not familiar with Python so I won't be able to help much. Unless someone who is familiar with it happens to see this post you probably won't get much help here. For coding specific issues, I recommend heading over to a site like Stack Overflow who is a better source for help.

Ok, thank you for answering me. Do not understand how JSON works or have a lot of results. I did a program, without any pretension. I post the other if we have the same problem.


print("type data = "+str(type(data)) )
chaine = str(data.decode('utf8')) 
comptTab=0
ch2=''
ii=0
while ii < len(chaine):
    if (chaine[ii]==','):
        if (chaine[ii+1] == '\"' ):
            ch2+=",\n"
            ch2+=("\t"*comptTab)

    elif (chaine[ii] == '{' ):
        ch2+="\n"
        ch2+=("\t"*comptTab)
        ch2+="{\n"
        comptTab+=1;
        ch2+=("\t"*comptTab)

    elif (chaine[ii]== '}'):
        ch2+="\n"
        comptTab-=1;
        ch2+=("\t"*comptTab)
        ch2+="}"
        ch2+=("\t"*comptTab)

    else:
        if( chaine[ii] == '\\'): # supprime les \\ et les d\
            if( chaine[ii+1] != '\\'):
                chaine[:-1] 
            else:
                ii = ii +1
        else:
            ch2+=chaine[ii]

    ii = ii +1

print(ch2)

Not sure if I quite get what you're going for either. Load data into json then it's a Python3 dict data structure. Can access data chunks by the keys then.

json_message = json.loads(data)
print(data['stuff'])

Negalite rasti filmo ar TV laidos? Prisijunkite, kad sukurtumėte.

Bendras

s susitelkti į paieškos juostą
p profilio meniu
esc uždarykite atidarytą langą
? spartieji klavišai

Medijų puslapiuose

b grįžkite atgal (arba tėvams leidus)
e į redagavimo puslapį

TV sezono puslapiuose

(dešinė rodyklė) sekantis sezonas
(kairė rodyklė) ankstesnis sezonas

TV epizodo puslapiuose

(dešinė rodyklė) sekantis epizodas
(kairė rodyklė) ankstesnis epizodas

Visuose atvaizdžio puslapiuose

a atverti atvaizdžio pridėjimo langą

Visuose redagavimo puslapiuose

t vertimo parinktys
ctrl+ s pateikti formą

Diskusijų puslapiuose

n sukurti naują diskusiją
w perjungti peržiūros būseną
p perjungti viešasis / privatus
c perjungti uždaryti / atidaryti
a peržiūrėti aktyvumą
r atsakyti į pokalbį
l į paskutinį atsakymą
ctrl+ enter pateikti pranešimą
(dešinė rodyklė) sekantis puslapis
(kairė rodyklė) ankstesnis puslapis

Nustatymai

Norite įvertinti ar įtraukti šį elementą į sąrašą?

Prisijungti