随笔分类 -  Python学习笔记——持续更新

这里记载学习python过程中遇到的新函数
摘要:1 tup = (['a','a1'],['b','b2'],['c','c3']) 2 ls = [['d',1,],['e',2],['f',3]] 3 b = [] 4 5 #for i in range(2): 6 # a = ls[0][i] + ":" + ls[1][i] + ":" 阅读全文
posted @ 2020-02-06 10:17 Mqqq 阅读(372) 评论(0) 推荐(0)
摘要:strip( )函数:去掉字符串头尾字符或序列。默认为去除空格和换行符 st = "1100110011" new_st = st.strip("1") print(new_st) st = "105555501" new_st = st.strip("10") print(new_st) st = 阅读全文
posted @ 2020-02-04 22:17 Mqqq 阅读(222) 评论(0) 推荐(0)
摘要:seed( a)函数:初始化随机数种子,只要种子相同,每次生成的随机数也相同。 randint( a,b)函数:随机生成[a,b]之间的整数。 import random random.seed('a') num1 = random.randint(0,3) num2 = random.randin 阅读全文
posted @ 2020-02-04 20:22 Mqqq 阅读(1846) 评论(0) 推荐(0)
摘要:format()函数: 功能一:排序功能 st1 = "{0} {1} {1}".format('a','b','c') print(st1) print("{first_name}·{last_name}".format(first_name = "slim",last_name = "shady 阅读全文
posted @ 2020-02-02 23:09 Mqqq 阅读(316) 评论(0) 推荐(0)
摘要:lcut()函数:分割字符串,返回一个列表。 lcut_for_search()函数:比lcut( )更加精准,但是会产生重复。 add_word( ) 函数:往分词词库里添加词语。 del_word( ) 函数:往分词词库里删除词语。 import jieba s = "思考快与慢的作者是丹尼尔卡 阅读全文
posted @ 2020-02-02 22:50 Mqqq 阅读(405) 评论(0) 推荐(0)
摘要:lambda()匿名函数 a = lambda x,y,z:(x+y)//z b = a(1,2,3) print(a(5,4,3)) print(b) 输出: 3 1 chr()函数 功能:返回整数(十进制或十六进制)对应的ASCII码 ord()函数 功能:返回字符对应的十进制数 a = chr 阅读全文
posted @ 2020-02-02 22:34 Mqqq 阅读(328) 评论(0) 推荐(0)
摘要:list()函数 功能:转变为列表。 tup = ('a','b','c') dic = {'a1':1,'b2':2,'c3':3} string = "武汉加油" list1 = list(tup) list2 = list(dic.keys()) list3 = list(dic.items( 阅读全文
posted @ 2020-02-02 22:19 Mqqq 阅读(1954) 评论(0) 推荐(0)