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。你有沒有看到這個問題? –