python全栈学习笔记

时间:2019-09-25 02:20来源: 操作系统
#作业回顾s = 11s1 = s.bit_length()prints = bool()prints = 'bhsdjshfa's3 = s[2::-2]printa = 'abisdugs'for i in a : print#字符串的拼接可以通过+实现s = 's132jsdihfsd's1 = s[1]+s[3]+s[2]printa = 'abisdugs'#while 实现遍历s =
#作业回顾
s = 11s1 = s.bit_length()prints = bool()prints = 'bhsdjshfa's3 = s[2::-2]printa = 'abisdugs'for i in a :    print

#字符串的拼接可以通过+实现
s = 's132jsdihfsd's1 = s[1]+s[3]+s[2]printa = 'abisdugs'

#while 实现遍历
s = 's132jsdihfsd'index = 0while 1:    print    index += 1    if index == len:        break

#输入个位数+个位数 实现求和(包括一个字符串转换)
content = input('>>>').strip()index = content.find("+")a = int(content[0:index])b = int(content[index:])c = a + bprint

# 求和对单个或多个数字进行求和。content = input(">>>").strip()col1 = content.split('+')sum = 0for i in col1:    sum += intprint#用户输入一系列数字字母,输出数字个数text = input('>>>')count = 0for i in text:    if i.isdigit():        count += 1print#等级信赖员工名字,按q输入。li = [1,'a','b',2,3,'a']while 1:    username = input('>>>')    if username.strip == 'Q':        break    else:        li.appendprint

#对列表进行增删改查

增加指定位置li.insert(4,'lskud h')printli.extend('二哥')li.extend([1,2,34,5])printli = [1,'a','b',2,3,'a']li.pop(1)name = li.pop()print删li.remove('a')print# li.clear()printdel li[2:]  #切片删除print#改li[0] = '男爵'printli[0:2]='yuandsaa'print#查for i in li :    printl = lenprints = li.count('d')printprint(li.index('d'))排序li = [1,324,6,5,765,342,3]#sort()正向排序li.sort()print#倒序li.sort(reverse=True)print#反转li.reverse()print

编辑: 操作系统 本文来源:python全栈学习笔记

关键词: