1.字符串转列表

2.列表转字符串

 

1. 字符串转列表

s ='hello python !'
li = s.split(' ') #注意:引号内有空格
print (li)
输出:
['hello', 'python', '!']

 

2. 列表转字符串

li = ['hello', 'python', '!']
s = ' '.join(li) #注意:引号内有空格
print(s)

输出:
hello python !

 

1.字符串转列表

2.列表转字符串

 

1. 字符串转列表

s ='hello python !'
li = s.split(' ') #注意:引号内有空格
print (li)
输出:
['hello', 'python', '!']

 

2. 列表转字符串

li = ['hello', 'python', '!']
s = ' '.join(li) #注意:引号内有空格
print(s)

输出:
hello python !

 

相关文章:

  • 2022-02-08
  • 2022-12-23
  • 2021-12-03
  • 2021-09-14
  • 2021-05-25
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案