一、字符串连接
s1 = 'hello' s2 = 'world' s3 = s1 + ' ' +s2 print(s3) #print: hello world
二、字符串反转
s1 = 'hello world' s2 = s1[::-1] print(s2) #print: dlrow olleh
三、字符串长度
s1 = 'hello world' ret = len(s1) print(ret) #print: 11
四、字符串包含
s1 = 'hello world' ret = 'h' in s1 print(ret) #print: true
五、字符串索引
s = 'fheiogfj' print(s[2]) #print: e print(s[:2]) #print: fh print(s[4:]) #print:ogfj
浙公网安备 33010602011771号