def str2tuple(*str):
    return str

# 字符串转元组
a='hh'
b=str2tuple(a)
print(b)

#列表转字符串,前提是列表里是字符串
b=['hello','haha']
c=''.join(b)
print(c)

#列表转元祖
list1=[123,22,44,55]
t1=tuple(list1)
print(t1)

#元组转字符串
t1=('aa','bb','cc')
t2=''.join(t1)
print(t2)

#元组转列表
t1=('aa','bb','cc')
print(list(t1))
print(list(t1[0]))#列表索引为0的字符串分开

#字符串转列表
a='hello'
print(list(a))#一个个分开的字符串
l1=list(str2tuple(a))
print(l1)#一整个字符串

 

相关文章:

  • 2021-07-30
  • 2021-09-24
  • 2021-09-20
  • 2022-12-23
  • 2021-12-03
  • 2021-07-09
  • 2022-12-23
  • 2021-10-10
猜你喜欢
  • 2021-06-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
  • 2022-01-16
  • 2022-12-23
相关资源
相似解决方案