簡體   English   中英

如何循環代碼以打印 json 文件中的下一個字符串,特別是 Email 字段。 PYTHON

[英]how can I loop the code to print the next string from my json file specifically the Email field. PYTHON

python代碼

import json

while True:
    with open('SNS DETAILS.json') as f:
        data = json.load(f)
        no = 0
        print(data[no]['Email'])

我希望它循環代碼並打印下一個 email 字段,然后循環並打印之后的一個,然后循環並打印下一個,等等。

她的 JSON 數據:

[    
    {
        "Email" : "",
        "Password" : ""
    },
    {
        "Email" : "",
        "Password" : ""
    }
]

對於不知道該怎么做的人,現在就在這里。 只需將 100 更改為您想要循環的最高數字。

import time
import json
x = -1
while x<100:
    x += 1
    time.sleep(10)
    with open('SNS DETAILS.json') as f:
        data = json.load(f)
        number = 0
        print(data[x]['Email'])

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM