python中给字符串赋值的几种方式

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/kaishihaohaozuoshi/article/details/82952657
# -*- coding:utf-8 -*-
s = 'abcdef'
s = list(s)
s[1] = 'E'
s = ''.join(s)
print s

s = s[0:1]+ 'E' +s[2:]
print s

s = s.replace('b','E')
print s

s = 'aEcdef'
print s

猜你喜欢

转载自blog.csdn.net/kaishihaohaozuoshi/article/details/82952657
今日推荐