0
これは本当に基本的なものになるだろうが、私はそれをどうやって行うのか忘れてしまった。 ":"で終わるリストの各文字列の最後の行を削除したいだけです。私は印刷し現時点で特定の文字で終了する場合、最後のSENTENCEを文字列で削除するには?
desc1 = ['A sentence. Another sentence', 'One more sentence. A sentence that finishes with:', 'One last sentence. This also finishes with a:']
for string in desc1:
if string.endswith(':'):
a = string.split('.')
b = a[:-1]
c = '.'.join(map(str, b))
print (c)
を持っている:
One more sentence
One last sentence
は、どのように私は今、それは次のように出力されるようにそれを得るのです:あなたは行く
['A sentence. Another sentence', 'One more sentence.', 'One last sentence.']
これ... javaのです。あなたはその質問を見ましたか? –