字符串与list一样可遍历、索引、切片、连接
但不能通过索引更改字符
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 11 13:33:59 2018
@author: myself
"""
word = "helloworld"
for i in (word): #字符串的遍历
print(i)
print(word[1]) #字符串的索引访问
print(word[-1])
print(word[0:2]) #字符串的切片
newWord = ",".join(word) #连接字符
print(newWord)
#错误:word[0] = "i"
#字符串不能通过索引更改字符
runfile('F:/Python/List30.py', wdir='F:/Python')
h
e
l
l
o
w
o
r
l
d
e
d
he
h,e,l,l,o,w,o,r,l,d