Python 内建函数 - ascii(object)

    xiaoxiao2021-03-25  74

    Manual直译实例

    Manual

    As repr(), return a string containing a printable representation of an object, but escape the non-ASCII characters in the string returned byrepr() using \x, \u or \U escapes. This generates a string similar to that returned byrepr() in Python 2.

    直译

    与repr()类似,返回包含一个可打印表示的对象的字符串,但字符串中的非ASCII(non-ASCII)字符通过使用\x, \u或\U转义符进行转义。生成的字符串与Python 2中的repr()的返回值相近。

    实例

    >>> ascii(10) '10' >>> ascii(900000) '900000' >>> ascii('100') "'100'" >>> ascii([0, 1, 2, 3]) '[0, 1, 2, 3]' >>> ascii('我去年买了个表') "'\\u6211\\u53bb\\u5e74\\u4e70\\u4e86\\u4e2a\\u8868'"
    转载请注明原文地址: https://ju.6miu.com/read-39052.html

    最新回复(0)