0
点赞
收藏
分享

微信扫一扫

python之字符串生成str(),repr()及' '


print type(str(1)) is str,
print type('1') is str,
print type(repr(1)) is str,


print type(str([1,2,3])) is str,

print isinstance(repr(123),str)

#output True True True True True

str() 的输出对用户比较友好,而repr()的输出对python比较友好。三者输出的内容一样,但是用

eval()把字符串当成表达式来求值。

eval(repr('abc'))=='abc'

#output True

举报

相关推荐

0 条评论