11# SOME DESCRIPTIVE TITLE.
2- # Copyright (C) 2001-2024 , Python Software Foundation
2+ # Copyright (C) 2001-2025 , Python Software Foundation
33# This file is distributed under the same license as the Python package.
44# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
55#
@@ -11,7 +11,7 @@ msgid ""
1111msgstr ""
1212"Project-Id-Version : Python 3.12\n "
1313"Report-Msgid-Bugs-To : \n "
14- "POT-Creation-Date : 2024-09-27 14:50 +0000\n "
14+ "POT-Creation-Date : 2025-02-07 14:52 +0000\n "
1515"PO-Revision-Date : 2024-05-11 00:33+0000\n "
1616"
Last-Translator :
Rafael Fontenelle <[email protected] >, 2024\n "
1717"Language-Team : Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n "
@@ -2889,6 +2889,150 @@ msgid ""
28892889" getcontext().prec -= 2\n"
28902890" return +s"
28912891msgstr ""
2892+ "def moneyfmt(value, places=2, curr='', sep=',', dp='.',\n"
2893+ " pos='', neg='-', trailneg=''):\n"
2894+ " \"\"\" 将 Decimal 值转换为以货币形式格式化的字符串。\n"
2895+ "\n"
2896+ " places: 小数点之后要保留的位数\n"
2897+ " curr: 正负号之前可选的货币符号 (可以为空)\n"
2898+ " sep: 可选的千位分隔符 (逗点, 句点, 空格或为空)\n"
2899+ " dp: 小数点符号 (逗点或句点)\n"
2900+ " 仅在保留零位小数时设为空\n"
2901+ " pos: 可选的正值符号: '+', 空格或为空\n"
2902+ " neg: 可选的负值符号: '-', '(', 空格或为空\n"
2903+ " trailneg:可选的末尾负值符号: '-', ')', 空格或为空\n"
2904+ "\n"
2905+ " >>> d = Decimal('-1234567.8901')\n"
2906+ " >>> moneyfmt(d, curr='$')\n"
2907+ " '-$1,234,567.89'\n"
2908+ " >>> moneyfmt(d, places=0, sep='.', dp='', neg='', trailneg='-')\n"
2909+ " '1.234.568-'\n"
2910+ " >>> moneyfmt(d, curr='$', neg='(', trailneg=')')\n"
2911+ " '($1,234,567.89)'\n"
2912+ " >>> moneyfmt(Decimal(123456789), sep=' ')\n"
2913+ " '123 456 789.00'\n"
2914+ " >>> moneyfmt(Decimal('-0.02'), neg='<', trailneg='>')\n"
2915+ " '<0.02>'\n"
2916+ "\n"
2917+ " \"\"\" \n"
2918+ " q = Decimal(10) ** -places # 2 个小数位 --> '0.01'\n"
2919+ " sign, digits, exp = value.quantize(q).as_tuple()\n"
2920+ " result = []\n"
2921+ " digits = list(map(str, digits))\n"
2922+ " build, next = result.append, digits.pop\n"
2923+ " if sign:\n"
2924+ " build(trailneg)\n"
2925+ " for i in range(places):\n"
2926+ " build(next() if digits else '0')\n"
2927+ " if places:\n"
2928+ " build(dp)\n"
2929+ " if not digits:\n"
2930+ " build('0')\n"
2931+ " i = 0\n"
2932+ " while digits:\n"
2933+ " build(next())\n"
2934+ " i += 1\n"
2935+ " if i == 3 and digits:\n"
2936+ " i = 0\n"
2937+ " build(sep)\n"
2938+ " build(curr)\n"
2939+ " build(neg if sign else pos)\n"
2940+ " return ''.join(reversed(result))\n"
2941+ "\n"
2942+ "def pi():\n"
2943+ " \"\"\" 计算 Pi 到当前精度。\n"
2944+ "\n"
2945+ " >>> print(pi())\n"
2946+ " 3.141592653589793238462643383\n"
2947+ "\n"
2948+ " \"\"\" \n"
2949+ " getcontext().prec += 2 # 用于中间步骤的额外位数\n"
2950+ " three = Decimal(3) # 替换常规浮点数的 \" three=3.0\" \n"
2951+ " lasts, t, s, n, na, d, da = 0, three, 3, 1, 0, 0, 24\n"
2952+ " while s != lasts:\n"
2953+ " lasts = s\n"
2954+ " n, na = n+na, na+8\n"
2955+ " d, da = d+da, da+32\n"
2956+ " t = (t * n) / d\n"
2957+ " s += t\n"
2958+ " getcontext().prec -= 2\n"
2959+ " return +s # 单目取正值运算将应用新的精度\n"
2960+ "\n"
2961+ "def exp(x):\n"
2962+ " \"\"\" 返回 e 的 x 次方。 结果类型将与输入类型相匹配。\n"
2963+ "\n"
2964+ " >>> print(exp(Decimal(1)))\n"
2965+ " 2.718281828459045235360287471\n"
2966+ " >>> print(exp(Decimal(2)))\n"
2967+ " 7.389056098930650227230427461\n"
2968+ " >>> print(exp(2.0))\n"
2969+ " 7.38905609893\n"
2970+ " >>> print(exp(2+0j))\n"
2971+ " (7.38905609893+0j)\n"
2972+ "\n"
2973+ " \"\"\" \n"
2974+ " getcontext().prec += 2\n"
2975+ " i, lasts, s, fact, num = 0, 0, 1, 1, 1\n"
2976+ " while s != lasts:\n"
2977+ " lasts = s\n"
2978+ " i += 1\n"
2979+ " fact *= i\n"
2980+ " num *= x\n"
2981+ " s += num / fact\n"
2982+ " getcontext().prec -= 2\n"
2983+ " return +s\n"
2984+ "\n"
2985+ "def cos(x):\n"
2986+ " \"\"\" 返回以弧度衡量的 x 的余弦。\n"
2987+ "\n"
2988+ " 泰勒级数近似算法对较小的 x 值效果最好。\n"
2989+ " 对于较大的值,则先计算 x = x % (2 * pi)。\n"
2990+ "\n"
2991+ " >>> print(cos(Decimal('0.5')))\n"
2992+ " 0.8775825618903727161162815826\n"
2993+ " >>> print(cos(0.5))\n"
2994+ " 0.87758256189\n"
2995+ " >>> print(cos(0.5+0j))\n"
2996+ " (0.87758256189+0j)\n"
2997+ "\n"
2998+ " \"\"\" \n"
2999+ " getcontext().prec += 2\n"
3000+ " i, lasts, s, fact, num, sign = 0, 0, 1, 1, 1, 1\n"
3001+ " while s != lasts:\n"
3002+ " lasts = s\n"
3003+ " i += 2\n"
3004+ " fact *= i * (i-1)\n"
3005+ " num *= x * x\n"
3006+ " sign *= -1\n"
3007+ " s += num / fact * sign\n"
3008+ " getcontext().prec -= 2\n"
3009+ " return +s\n"
3010+ "\n"
3011+ "def sin(x):\n"
3012+ " \"\"\" 返回以弧度衡量的 x 的正弦。\n"
3013+ "\n"
3014+ " 泰勒级数近似算法对较小的 x 值效果最好。\n"
3015+ " 对于较大的值,则先计算 x = x % (2 * pi)。\n"
3016+ "\n"
3017+ " >>> print(sin(Decimal('0.5')))\n"
3018+ " 0.4794255386042030002732879352\n"
3019+ " >>> print(sin(0.5))\n"
3020+ " 0.479425538604\n"
3021+ " >>> print(sin(0.5+0j))\n"
3022+ " (0.479425538604+0j)\n"
3023+ "\n"
3024+ " \"\"\" \n"
3025+ " getcontext().prec += 2\n"
3026+ " i, lasts, s, fact, num, sign = 1, 0, x, 1, x, 1\n"
3027+ " while s != lasts:\n"
3028+ " lasts = s\n"
3029+ " i += 2\n"
3030+ " fact *= i * (i-1)\n"
3031+ " num *= x * x\n"
3032+ " sign *= -1\n"
3033+ " s += num / fact * sign\n"
3034+ " getcontext().prec -= 2\n"
3035+ " return +s"
28923036
28933037#: ../../library/decimal.rst:2054
28943038msgid "Decimal FAQ"
@@ -3165,9 +3309,9 @@ msgstr ""
31653309
31663310#: ../../library/decimal.rst:2248
31673311msgid ""
3168- "For inexact results, :attr :`MAX_PREC` is far too large on 64-bit platforms "
3312+ "For inexact results, :const :`MAX_PREC` is far too large on 64-bit platforms "
31693313"and the available memory will be insufficient::"
3170- msgstr "对于不精确的结果,在 64 位平台上 :attr:`MAX_PREC` 的值太大了,可用的内存将会不足:: "
3314+ msgstr ""
31713315
31723316#: ../../library/decimal.rst:2251
31733317msgid ""
0 commit comments