【发布时间】:2020-05-29 09:18:54
【问题描述】:
我正在尝试打印主要的总称,但每次我这样做时,它每行返回一个字符,我该如何制作才能将整个总称打印在一行中。
结果:
@
g
m
a
i
l
.
c
o
m
预期结果:@gmail.com
JSON 代码:
{
"primaryCatchall": "@gmail.com",
"secondaryCatchall": "@gmail.com",
"password": "password123",
"repeat": 5
}
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)
【问题讨论】:
-
嗨 503ryan,这里已经回答了 stackoverflow.com/questions/3249524/…,如果您使用 Python 3,您只需将
print(primaryCatchall)更新为print(primaryCatchall, end="")
标签: python json python-3.x