Python---string

'''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'))

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值