我有一個領域:
overtime_50 = fields.Char(readonly=True, default='00:00')
我列出了這個領域,我得到了很多串列:
def _compute_sum_50(self):
for record in self:
x = [record.overtime_50]
print(x)
控制臺列印:
['00:00']
['00:00']
['00:00']
['00:00']
['00:00']
['00:00']
['00:00']
['00:00']
['00:00']
['00:00']
['00:00']
我需要得到這樣的東西:
['00:00','00:00','00:00','00:00','00:00','00:00','00:00','00:00','00:00']
我嘗試了很多方法,但我只能得到這樣的結果:
def _compute_sum_50(self):
for record in self:
x = [record.overtime_50]
print(list(chain.from_iterable(x)))
控制臺列印:
['0', '0', ':', '0', '0']
['0', '0', ':', '0', '0']
['0', '0', ':', '0', '0']
['0', '0', ':', '0', '0']
['0', '0', ':', '0', '0']
['0', '0', ':', '0', '0']
['0', '0', ':', '0', '0']
['0', '0', ':', '0', '0']
['0', '0', ':', '0', '0']
['0', '0', ':', '0', '0']
['0', '0', ':', '0', '0']
我能做錯什么?
uj5u.com熱心網友回復:
def _compute_sum_50(self):
x = []
for record in self:
x.append(record.overtime_50)
print(x)
您必須使用附加功能-
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/339442.html
標籤:Python 列表 奥杜 python-3.6
