Detailed introduction to Python's built-in ascii function

高洛峰
Release: 2017-03-21 11:35:17
Original
2295 people have browsed it

英文文档:

ascii(object)

Asrepr(),returnastringcontaining aprintable representation of an object, but escape the non-ASCII characters in the string returned byrepr()using\x,\uor\Uescapes. This generates a string similar to that returned byrepr()inPython2.

说明:

1. 返回一个可打印的对象字符串方式表示,如果是非ascii字符就会输出\x,\u或\U等字符来表示。与python2版本里的repr()是等效的函数。

>>> ascii(1) '1' >>> ascii('&') "'&'" >>> ascii(9000000) '9000000' >>> ascii('中文') #非ascii字符 "'\\u4e2d\\u6587'"
Copy after login

The above is the detailed content of Detailed introduction to Python's built-in ascii function. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!