'''help--string'''
import sys
import util_m
list_1=[1,43,161,12]
i=0
for item in list_1:
if item%2!=0:
print(item)
i=i+1
else:
break
print('total:')
print(i)
name='xfei'
password='123456'
print("{0}'s password is {1}".format(name, password))
list_2=['bit','byte','char','short','int','long','double']
string1= '{0[0]} is smaller than {0[2]}'.format(list_2)
print(string1)
'''pay attention to the location of the symbol {}'''
string2='{0.modules[util_m].list1[0]}'.format(sys)
print(string2)
string3='''This is
My first
test
Example'''
print(string3.splitlines())
print(string3.lower())
print(string3.lower().count('i'))
string4='''username=xfei&password=123'''
string5=string4.split('&')
print(string5)
list6 = [v.split('=',6) for v in string5]
print(list6)
print(dict(list6))
string6='''this is my first example'''
list7=string6[1:]
print(list7)
byte1=b'abcde\x66'
print(byte1)
print(len(byte1))
print(byte1+b'\xff')
'''x00~xff'''
barr=bytearray(byte1)
print(barr)
barr[0]=77
print(barr[0])
string9='abbbcdefgbbbb'
byte2=b'b'
print(string9.count(byte2.decode('ascii')))
string10='likepython'
'''python3 use utf-8, python2 use ascii'''
byte3=string10.encode('utf-8')
print(byte3)
byte3=string10.encode('big5')
print(byte3)
print(len(string10))
print(byte3.decode('big5'))
Python---string
最新推荐文章于 2023-07-01 15:28:46 发布