name ="hello python" print(name[6]) ### qiepian capzuo name1 = "abcdefg" print(name1[2:5:1]) print(name1[2:5]) print(name1[:5]) print(name1[1:]) print(name1[:]) print(name1[::2]) print(name1[:-1])#-1表示最后一个数 ### 字符串find操作 myster = "hello word and hello python" print(myster.find("hello")) print(myster.find("hello",10,27)) print(myster.find("student")) print(myster.find("hello")) print(myster.find("hello",10,27)) print(myster.find("student")) ### rfind myster1 = "python.png" print(myster1.rfind(".png")) print(myster1.rfind(".png")) print(myster1.rfind(".png")) ### count myster2 = "hello word and hello python hello web" print(myster2.count("hello")) ### count myster2 = "hello word and hello python hello web" print(myster2.count("h")) ### 字符串修改 myster3 = "hello word and hello python" print(myster3.replace("and","&")) print(myster3.replace("hello","hellow")) ### 按照指定字符分割字符串 myster4 = "apple,orange,banana" print(myster4.split(",")) print(myster4.split(",",1)) print(myster4.split("*")) ### join():用一个字符或字串合并字符串,并把 name2 = "hellow" name3 = "world" print(name2.join(name3)) ### 将字符第一个字符大写,其他小写 myster5 = 'studenT' print(myster5.capitalize() ) ###