标签:split() -- nbsp 类型 join lse class bsp list
1、int 与bool 的转换
# int转化成bool:非0转换成bool是TRUE,0转换成bool是False print(bool(2)) print(bool(-2)) print(bool(0)) # bool-->int print(int(True)) # 1 print(int(False)) # 0
2、int与str的转换
# int ----> str i = 1 s = str(i) # str ---> int s = ‘123‘ i = int(s)
3、str与bool的转换
# int ----> str i = 1 s = str(i) # str ---> int s = ‘123‘ i = int(s)
4、str与list的转换
# split str--->list s = ‘:alex:wusir:taibai‘ l = s.split(‘:‘) print(l) #列表转化成字符串 list -----> str join li = [‘taibai‘,‘alex‘,‘wusir‘,‘egon‘,‘女神‘,] s = ‘‘.join(li) # str ----->list split() print(s) s1 = s.split(‘‘) print(s1)
标签:split() -- nbsp 类型 join lse class bsp list
原文地址:https://www.cnblogs.com/nanguajiejie/p/10124268.html