[英]JSON file prints one character per line
I am trying to print the primary catchall but every time I do it it returns one character per line, how do I make it so it prints the whole catchall in one line.我正在尝试打印主要的总称,但每次我这样做时,它每行返回一个字符,我该如何制作它以便将整个总称打印在一行中。
Result:结果:
@
g
m
a
i
l
.
c
o
m
Expected result: @gmail.com预期结果:@gmail.com
JSON Code: JSON 代码:
{
"primaryCatchall": "@gmail.com",
"secondaryCatchall": "@gmail.com",
"password": "password123",
"repeat": 5
}
Python code: Python代码:
import json
with open('tempemail.txt', 'r') as myfile1:
email1 = myfile1.read()
with open('config.json', 'r') as config:
PrimaryCatchall = json.load(config)
for primaryCatchall in PrimaryCatchall['primaryCatchall']:
with open('accounts.txt', 'a') as accounts:
print(primaryCatchall)
#accounts.write("\n")
#accounts.write(email1)
#accounts.write(primaryCatchall)
In your code, you loaded your JSON as the variable PrimaryCatchall.在您的代码中,您将 JSON 作为变量 PrimaryCatchall 加载。 Right afterward, you ran a for loop for PrimaryCatchall, which got each individual character.紧接着,你为 PrimaryCatchall 运行了一个for 循环,它得到了每个单独的字符。 Get rid of that for loop to fix the problem摆脱那个for循环来解决问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.