This commit is contained in:
qsc
2025-09-30 21:19:02 +08:00
parent d8dac64b1d
commit 8440329fbc
2 changed files with 40 additions and 4 deletions
+21 -1
View File
@@ -83,4 +83,24 @@ def extract_field(data_list, field_name):
Returns:
list: 提取出来的字段值列表
"""
return [item[field_name] for item in data_list if field_name in item]
return [item[field_name] for item in data_list if field_name in item]
def gold_to_string(gold_amount):
"""
将金钱数值转换为字符串表示形式
Args:
gold_amount (int): 金钱数值,单位为铜币
Returns:
str: 格式化后的金钱字符串,例如 "1金2银3铜"
"""
bricks = gold_amount // 100000000 if gold_amount else 0
gold = (gold_amount % 100000000) // 10000 if gold_amount else 0
silver = (gold_amount % 10000) // 100 if gold_amount else 0
copper = gold_amount % 100 if gold_amount else 0
gold_str = f"{bricks}{gold}{silver}{copper}" if gold_amount else "无价格"
return gold_str