Python ဖော် မတ်() လုပ်ဆောင်ချက်
ဥပမာ
နံပါတ် 0.5 ကို ရာခိုင်နှုန်းတန်ဖိုးအဖြစ် ပုံစံဖော်ပါ-
x =
format(0.5, '%')
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
လုပ်ဆောင်ချက် သည် format()
သတ်မှတ်ထားသောတန်ဖိုးကို သတ်မှတ်ဖော်မတ်တစ်ခုအဖြစ် ဖော်မတ်ပေးသည်။
အထားအသို
format(value,
format)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
value | A value of any format |
format | The format you want to format the value into. Legal values: '<' - Left aligns the result (within the available space)'>' - Right aligns the result (within the available space)'^' - Center aligns the result (within the available space)'=' - Places the sign to the left most position'+' - Use a plus sign to indicate if the result is positive or negative'-' - Use a minus sign for negative values only' ' - Use a leading space for positive numbers',' - Use a comma as a thousand separator'_' - Use a underscore as a thousand separator'b' - Binary format'c' - Converts the value into the corresponding unicode character'd' - Decimal format'e' - Scientific format, with a lower case e'E' - Scientific format, with an upper case E'f' - Fix point number format'F' - Fix point number format, upper case'g' - General format'G' - General format (using a upper case E for scientific notations)'o' - Octal format'x' - Hex format, lower case'X' - Hex format, upper case'n' - Number format'%' - Percentage format
|
နောက်ထပ် ဥပမာများ
ဥပမာ
255 ကို ဆဋ္ဌမတန်တန်ဖိုးအဖြစ် ဖော်မတ်ပါ-
x = format(255, 'x')