字符串的赋值
a = "hello"
b = 'westos'
c = "what's up"
d = """
用户管理
1.添加用户
2.删除用户
3.显示用户
"""
# 索引:0,1,2,3,4 索引值是从0开始
s = 'hello'
print s[0]
print s[1]
# 切片
print s[0:3] # 切片的规则:s[start:end:step] 从start开始到end-1结束,步长:step
print s[0:4:2]
# 显示所有字符
print s[:]
# 显示前3个字符
print s[:3]
# 对字符串倒叙输出
print s[::-1]
# 除了第一个字符以外,其他全部显示
print s[1:]
# 重复
print s * 10
# 连接
print 'hello ' + 'world'
# 成员操作符
print 'q' in s # s字符串中是否含有q
print 'he' in s
print 'aa' in s
s = 'hello.jpg'
# 找出字符串是否以XXX结尾
print s.endswith('.png')
url1 = 'http://www.baidu.com'
url2 = 'file:///mnt'
print url1.startswith('http://') # url1是否以http://开头
print url2.startswith('f')
# 判断字符串里面的每个元素是否为什么类型
# 一旦有一个元素不满足,就返回False
print '123'.isdigit()
print '123abc'.isdigit()
# title:标题 判断某个字符串是否为标题(第一个首字母大写,其余字母小写)
print 'Hello'.istitle()
print 'HeLlo'.istitle()
print 'hello'.upper() # 将某个字符串转化为大写
print 'hello'.islower() # 判断某个字符串是否为小写
print 'HELLO'.lower() # 将某个字符串转化为小写
print 'HELLO'.isupper() # 判断某个字符串是否为小写
print 'hello'.isalnum() # 判断某个字符串是否为小写和数字
print '123'.isalpha() # 判断某个字符串是否为字母
print 'qqq'.isalpha()
s = 'hello world'
#print len(s)
# find找到字符串 并返回最小的索引
print s.find('hello')
print s.find('world')
print s.replace('hello','westos')
print 'helloooo'.count('o')
"""
# split对于字符串进行分离,分割符为'.'
s = '172.25.254.250'
s1 = s.split('.')
print s1
date = '2018-8-27'
date1 = date.split('-')
print date1
# 连接
print ''.join(date1)
print '/'.join(date1)
print '/'.join('hello')