摘要: •turtle的使用 #设置窗体大小 startx,starty非必需,默认在屏幕中间 turtle.setup(width,height,startx,starty) #海龟到(x,y)坐标 turtle.goto(x , y) #海龟向前移动d #当d值为正数时向前移动 #当d为负数时向后移动 阅读全文
posted @ 2021-01-30 16:13 MMMMinoz 阅读(184) 评论(0) 推荐(1) 编辑
摘要: •random的使用 import random as ran import time as t ran.seed(123) darts = eval(input()) hits = 0.0 start = t.perf_counter() for i in range(1,darts+1): x, 阅读全文
posted @ 2021-01-30 15:34 MMMMinoz 阅读(87) 评论(0) 推荐(0) 编辑
摘要: •wordcloud使用方法 常规使用方法 import wordcloud #创建一个词云对象 w = wordcloud.WordCloud(background_color="white") #向WordCloud对象w中加载文本txt txt1 = "life is short,you ne 阅读全文
posted @ 2021-01-30 15:17 MMMMinoz 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 文件使用 •文件的打开模式 •文件的操作方法 #一次读入 f = open("output","r") txt = f.read() ... f.close() #按数量读入,一次读k长度 f = open("output","r") txt = f.read(k) ... f.close() #分 阅读全文
posted @ 2021-01-30 15:02 MMMMinoz 阅读(120) 评论(0) 推荐(0) 编辑
摘要: jieba库用来对中文进行分词 import jieba #精确模式,返回一个列表类型的分词结果 # jieba.lcut(s) print(jieba.lcut("python是一门编程语言")) #全模式,返回一个列表的分词结果,存在冗余 # jieba.lcut(s,cut_all=True) 阅读全文
posted @ 2021-01-30 14:45 MMMMinoz 阅读(143) 评论(0) 推荐(0) 编辑
摘要: •set类(去重) 列表有序,集合无序 S = {'P','Y','t','h','O','n'} T = {'P','Y','T'',h','o','n'} S - T#差 S | T#并 S & T#交 S ^ T#补 S >= T (S <= T) #判断包含关系 S.add(x)#向S中添加 阅读全文
posted @ 2021-01-30 14:40 MMMMinoz 阅读(111) 评论(0) 推荐(0) 编辑
摘要: time库包括三类函数 •时间获取 time(),ctime(),gmtime() 时间格式化:strftime() strptime() 程序计时:sleep(),perf_counter() # %Y年份 %m月份 %B月份名称 %b月份名简写 %d日期 # %A星期 %a星期简写 %H24制时 阅读全文
posted @ 2021-01-30 13:43 MMMMinoz 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 字符串类型 •字符串的表示 字符串是字符的有序序列。 由一对单引号或双引号表示,仅表示单行字符串 由一对三引号表示,可表示多行字符串,也是一种注释方式 •字符串的序号 •字符串的使用 s = "请输入带有符号的温度值:" s[i] #返回字符串中第i个字符 s[m:n] #返回字符串中[m,n)的字 阅读全文
posted @ 2021-01-30 12:45 MMMMinoz 阅读(265) 评论(0) 推荐(0) 编辑