2019-02-18
阅读量:
716
python str 与 repr 用法是啥?
python str 与 repr 用法是啥?
答:python可以通过使用str 与 repr 这两种机制将值转换为字符串。
str 能将特殊编码转换为相应的字符
print(str'hello \nworld')
输出:
hello
world
repr 能将值转换为合法python表达式
print(repr'hello \nworld')
输出:'hello \nworld'






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论