输入:
question1 = content[0],"\n",content[1]
print(question_order[0])
输出:
('How secret should you keep your passwords? \n', '\n', 'A)Never give out passwords except to your parents B)Give them only to your best friends C)Give them to strangers \n')
答案 0 :(得分:0)
因为你对你的问题很模糊,这是我能做的最好的事情:
print([i.replace('\n', '') for i in question_order[0] if i.replace('\n', '') != ''])
答案 1 :(得分:0)
你的问题太模糊了。
如果content
不是外部参考,并且是由您创建的,我建议在存储它们之前从数据中删除空格。
如果无法根据其定义删除content
,建议您在将其附加到question1
之前从已删除的值中question_order
形成{假设,question_order
是一个集合与question1
)相同的类型。
question1 = content[0].strip(),"\n",content[1].strip()
print(question1)
将打印:
('How secret should you keep your passwords?', '\n', 'A)Never give out passwords except to your parents B)Give them only to your best friends C)Give them to strangers')