I have a list which collect data, and at one point it returns None and i need to replace this None with a 0. How can i get this done in openerp 7
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Księgowość
- Zapasy
- PoS
- Project
- MRP
To pytanie dostało ostrzeżenie
You can iterate the list and check the condition. If you get None value it will insert 0 in new list.
>>> a = [1,2,3,'c',None]
>>> b = []
>>> for x in a:
... if x is None:
... b.append(0)
... else:
... b.append(x)
...
>>> b
[1, 2, 3, 'c', 0]
Thank You @Krutarath,
Already i have done that this way,
late_duration = [['a', 1], ['b', 4], ['c', None]]
late_duration_val_list = [[None if isinstance(b, int) else 0 if b == None else b for b in i] for i in late_duration]
late_duration.append(late_duration_val_list)
print (late_duration_val_list)
Output is,
[['a', None], ['b', None], ['c', 0]]
Podoba Ci się ta dyskusja? Dołącz do niej!
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj sięPowiązane posty | Odpowiedzi | Widoki | Czynność | |
---|---|---|---|---|
|
3
sie 15
|
22645 | ||
|
1
mar 15
|
6286 | ||
|
0
lut 16
|
2929 | ||
|
2
sie 15
|
6681 | ||
|
1
sie 15
|
4630 |