一、字符串
01. 给定一个字符串str = “helloworld”,利用所学字符串的切片知识,反转字符串
代码:
str = 'helloworld';
print(str[::-1]);#利用切片反转字符串
结果:
02. 给定一个字符串str = “my name is baoabo”,将“ ”(空格)替换为“,”,并输出显示
代码:
str = 'my name is baoabo';
#使用replace把字符串中空格替换为','
print(str.replace(' ',','));
结果: