美好的一天,我有一個 ICD 10 代碼串列,例如 U07.01、Z152.8154、X98.23 等。它們由 WHO 提供
我想在 Odoo 中將其四舍五入為 U07.0、Z152.8、X98.2,我嘗試使用內置圓形但它給出了錯誤。這是我的代碼....
code.text = round(str(patient_line.doc_disease_id.code).lower(), 1) or ' '
uj5u.com熱心網友回復:
使用str slicing. 例如:
l = ['U07.01', 'Z152.8154', 'X98.23']
new_list = []
for i in l:
first_part, second_part = str(i).split('.')
second_part = second_part[:1]
new = f'{first_part}.{second_part}'
new_list.append(new)
print(new_list)
根據OP 的需要,一次只使用一個代碼:
first_part, second_part = str(old_code).split('.')
second_part = second_part[:1]
new = f'{first_part}.{second_part}'
print(new)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/367011.html
標籤:Python 蟒蛇-3.x python-2.7 奥杜
