Film Veritabanı Desteği

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 yanıt (toplam 1 sayfanın 1.sayfasında)

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'])

Bir filmi veya diziyi bulamıyor musun? Eklemek için oturum aç.

Küresel

s arama çubuğuna odaklan
p profil menüsünü aç
esc açık bir pencereyi kapat
? klavye kısayol penceresini aç

Medya sayfalarında

b geri git (veya uygulanabilirse ana ekrana)
e sayfayı düzenlemeye git

TV sezonu sayfalarında

(sağa ok) sonraki sezona git
(sol ok) önceki sezona git

TV bölüm sayfalarında

(sağa ok) sonraki bölüme git
(sol ok) önceki bölüme git

Tüm görüntü sayfalarında

a resim ekle penceresini aç

Tüm düzenleme sayfalarında

t çeviri seçiciyi aç
ctrl+ s formu gönder

Tartışma sayfalarında

n yeni tartışma oluştur
w izleme durumunu değiştir
p umumi/hususi değiştir
c kapalı/açık değiştir
a etkinliği aç
r tartışmayı yanıtla
l son yanıta git
ctrl+ enter mesajını gönder
(sağa ok) sonraki sayfa
(sol ok) önceki sayfa

Ayarlar

Bu öğeyi derecelendirmek veya bir listeye eklemek ister misiniz?

Giriş