Python的特殊属性和用法 ... ③ 字符串的“非正式”值 str(x) x.__str__() ④ 字节数组的“非正式”值 bytes(x) x.__bytes__() ⑤ 格式化字符串的值 format(x, format_spec) x.__format__(format_spec) ...
基于1个网页-相关网页
格式化将类型的值转化为字符串表示形式;分析则与格式化相反,它是从字符串表示形式创建数据类型。
Formatting converts the value of a type into a string representation; parsing, the inverse of formatting, creates a data type from a string representation.
如果格式化的值在格式字符串中出现“0”的位置有一个数字,则此数字被复制到结果字符串中。
If the value being formatted has a digit in the position where the '0' appears in the format string, then that digit is copied to the result string.
此方法采用某个枚举格式化字符串指定希望返回的值。
This method takes one of the enumeration formatting strings to specify the value that you want returned.
应用推荐