w1w 发表于 2017-5-1 06:36:10

python str()与repr()区别

The str() function is meant to return representations of values which are fairly
human-readable, while repr() is meant to generate representations which can be read by
the interpreter (or will force a SyntaxError if there is not equivalent syntax).
str是给人看的,repr是给编译器看的,同时eval(repr(obj))还可以得到obj。
页: [1]
查看完整版本: python str()与repr()区别