python - python输入输出之str与repr函数

如果将输出的值转成字符串,可以使用 repr() 或 str() 函数来实现。

str() #称为“用户友好形式”,函数返回一个用户易读的表达形式。

repr() #称为“全精度形式”,产生一个解释器易读的表达形式。

例子:

>>> str(0.1)

'0.1'

>>> repr(0.1)

'0.10000000000000001'

猜你喜欢

转载自blog.csdn.net/helunqu2017/article/details/114610559