str()

str() 用于将一个对象转换为字符串

In [1]: str(10)    # 将整数转换成字符串
Out[1]: '10'

In [2]: str([1, 2, 3])    # 将列表转换成字符串
Out[2]: '[1, 2, 3]'

In [3]: str((1, 2, 3))    # 将元组转换成字符串
Out[3]: '(1, 2, 3)'

    

原文地址:https://www.cnblogs.com/pzk7788/p/10258861.html