Python类型转换

>> int 转 str

  s = str(i)  # 无条件转换

>> str 转 int

  i = int(s)  # 字符串必须是数字;否则语法报错

>> int 转 bool

  b = bool(i)  # 非0即为Ture

>> str 转 bool

  b = bool(s)  # “” 什么都没有为False否则为Ture

        # “0” 为Ture

 >>bool转str

原文地址:https://www.cnblogs.com/mqxBlog/p/9795716.html