首页 > 其他 > 详细

Input and Output

时间:2018-06-18 14:23:14      阅读:237      评论:0      收藏:0      [点我收藏+]

Python has ways to convert any value to a string: pass it to the repr() or str() functions.

这两者都是将值转变为string类型,但是有区别:

str()得到的string类型变量会执行转义等命令,而repr()则直接照搬。

hello = hello, world\n
hellos = repr(hello)
helloss = str(hello)
print(hellos)
print(helloss)
print(hellos)


hello, world\n
hello, world

hello, world\n

 

Input and Output

原文:https://www.cnblogs.com/xuhaojun/p/9195086.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!