- 博客(4)
- 收藏
- 关注
原创 Python编程快速上手 7.18.2 strip()的正则表达式
import re def fn(strtemp,char=r'\s'): regex = r'^%s*|%s*$'%(char,char) strregex = re.compile(regex) s = strregex.sub('',strtemp) return s print(fn(' sss ')) print(fn('aasssaa','a'))
2018-07-19 16:56:47 1164
原创 Python编程快速上手 7.18.1 强口令检测
import re while True: pw = input('请输入口令:') if pw == 'q': break elif re.match(r'^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,}$',pw): print('强口令') else: print('若口令')
2018-07-19 14:17:11 673 1
原创 python编程快速上手 -- 6.7 实践项目(表格打印)
tableData = [['apples', 'oranges', 'cherries', 'banana'], ['Alice', 'Bob', 'Carol', 'David'], ['dogs', 'cats', 'moose', 'goose']] def printTable(tableData): maxlist = [] for i in tableDa...
2018-07-16 17:40:24 1077 1
原创 python编程快速上手 -- 5.6.2 列表到字典的函数,针对好玩游戏物品清单
def displayInventory(stuff): num = 0 print('Inventory:') for i,v in stuff.items(): print(str(v)+' '+i) num += v print('Total number of items:%d'%num) def addToInventory(inventory,dragonLoot):...
2018-07-13 17:52:52 682 1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人