class Sample:
def __init__(self):
self.lst_report_footer_strings = ['Manager', 'Accountant', 'Created By',
'fifth', '', '']
int_size_of_string = 0
lst_temp_report_footer = self.lst_report_footer_strings
for lst_report_footer_item in self.lst_report_footer_strings:
print lst_temp_report_footer
print lst_report_footer_item
if lst_report_footer_item in ('', ' '):
print "Inside if : Item ==" + lst_report_footer_item
lst_temp_report_footer.remove(lst_report_footer_item)
print "list after remove == " + str(lst_temp_report_footer)
else:
print "Inside else : length = ", str(len(lst_report_footer_item))
int_size_of_string += len(lst_report_footer_item)
if __name__ == '__main__':
ins_class = Sample()
['Manager', 'Accountant', 'Created By', 'fifth', '', '']
Manager
Inside else : length = 7
['Manager', 'Accountant', 'Created By', 'fifth', '', '']
Accountant
Inside else : length = 10
['Manager', 'Accountant', 'Created By', 'fifth', '', '']
Created By
Inside else : length = 10
['Manager', 'Accountant', 'Created By', 'fifth', '', '']
fifth
Inside else : length = 5
['Manager', 'Accountant', 'Created By', 'fifth', '', '']
Inside if : Item ==
list after remove == ['Manager', 'Accountant', 'Created By', 'fifth', '']
我需要的是....
list after remove == ['Manager', 'Accountant', 'Created By', 'fifth']
@Igor謝謝你的編輯,很難理解OP和他的代碼。 – 2012-08-01 10:48:41
@lagor:感謝您的編輯。這是我第一次發佈代碼。對不起 – 2012-08-01 11:00:47
如果您找到了解決方案,請從其中一個答案(我認爲您有答案)中將其標記爲這樣。我只提醒你這一點,因爲你提到你是該網站的新手。 – 2012-08-01 11:48:28