缥缈止盈
这是一个简单的解决方案(在Python 3中):dates = ['Monday 30 March', '', '', '', '', '', '', '', '', '', 'Tuesday 31 March', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'Wednesday 1 April', '', '', '', '', '', '', '', '', '', '', '', '', '', ''] newdates = []current = ''for item in dates: if not item: newdates.append(current) else: current = item newdates.append(current)print(dates)print(newdates)带输出:['Monday 30 March', '', '', '', '', '', '', '', '', '', 'Tuesday 31 March', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'Wednesday 1 April', '', '', '', '', '', '', '', '', '', '', '', '', '', '']['Monday 30 March', 'Monday 30 March', 'Monday 30 March', 'Monday 30 March', 'Monday 30 March', 'Monday 30 March', 'Monday 30 March', 'Monday 30 March', 'Monday 30 March', 'Monday 30 March', 'Tuesday 31 March', 'Tuesday 31 March', 'Tuesday 31 March', 'Tuesday 31 March', 'Tuesday 31 March', 'Tuesday 31 March', 'Tuesday 31 March', 'Tuesday 31 March', 'Tuesday 31 March', 'Tuesday 31 March', 'Tuesday 31 March', 'Tuesday 31 March', 'Tuesday 31 March', 'Tuesday 31 March', 'Tuesday 31 March', 'Tuesday 31 March', 'Tuesday 31 March', 'Tuesday 31 March', 'Wednesday 1 April', 'Wednesday 1 April', 'Wednesday 1 April', 'Wednesday 1 April', 'Wednesday 1 April', 'Wednesday 1 April', 'Wednesday 1 April', 'Wednesday 1 April', 'Wednesday 1 April', 'Wednesday 1 April', 'Wednesday 1 April', 'Wednesday 1 April', 'Wednesday 1 April', 'Wednesday 1 April', 'Wednesday 1 April']