如果一个句子以双空格开头,我需要忽略该行并检查其他行。如果没有,我需要打印该行。我是python的新手,请帮我解决这个问题。
2 回答

大话西游666
TA贡献1817条经验 获得超14个赞
这很简单。您可以检查字符串的第一个字符是否为. 见下面的例子
sentences = [' this wont print', 'this will print', " this wont print either", " this will print"]
for sentence in sentences:
if sentence.startswith(' '):
print(sentence)
添加回答
举报
0/150
提交
取消