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。

你可能感兴趣的:(python)