#coding:utf-8
# string clice
a_string='my alpert starts where your alphabet ends.'
print a_string[3:21]
print a_string[0:2]
print a_string[:18]
print a_string[18:]
#
by = b'abcd\x65'
print by #abcde
print type (by) #<type 'str'>
print len(by) #5
#by += b'\xff'
#print by
print by[0]
barr = bytearray(by)
print barr #abcde
#常用的字符串方法
s = ''' finish flies are the re0-
sult of years of scientific
... study combined with the
... experice of yeaer.. '''
s.splitlines()
print s.splitlines() ##r多行输入作为参数,返回一个字符串列表,列表的元素是原来的单行字符串
print s.upper()
print s.upper().count('F')
query = 'user=test&database=master&password=123456'
a_list = query.split('&')
print a_list #['user=test', 'database=master', 'password=123456']
a_list_of_lists=[v.split('=',1) for v in a_list]
print a_list_of_lists #[['user', 'test'], ['database', 'master'], ['password', '123456']]
a_dict = dict(a_list_of_lists)
print a_dict #{'password': '123456', 'user': 'test', 'database': 'master'}
python--spring练习2
最新推荐文章于 2023-05-06 09:04:22 发布