自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(14)
  • 收藏
  • 关注

原创 猜数字 限制五次

import randomimport tkinterimport sysimport tkinter.messageboxdef cai_shu_zi(): global i if Button1['text'] == "游戏结束": sys.exit() else: try: text_check = ''.join(j for j in Entry1.get() if j in '0123456789')

2020-12-24 09:31:21 684 1

原创 有次数限制的猜数字

import randomimport tkinterimport sysimport tkinter.messageboxdef cai_shu_zi(): global i if Button1['text'] == "游戏结束": sys.exit() else: try: text_check = ''.join(j for j in Entry1.get() if j in '0123456789')

2020-12-23 19:53:49 244

原创 BMI 猜数字

import tkinter as tkimport randomroot = tk.Tk()root.title('猜数字游戏')tk.Label(root, text="请输入一个1——100之间的整数:").grid(row=0, column=0)entry1 = tk.Entry(root) entry1.grid(row=0, column=1, padx=10, pady=10)random_num = random.randint(1, 100)

2020-12-13 16:20:21 84 1

原创 tkBMI

import tkinter as tk#创建页面root = tk.Tk()#给程序窗口命名root.title('计算BMI')#创建文本信息tk.Label(root, text="体重(kg):").grid(row=0, column=0)tk.Label(root, text="身高(m):").grid(row=1, column=0)#创建输入框entry1 = tk.Entry(root) entry2 = tk.Entry(root)entry1.grid(ro

2020-12-13 16:19:10 94

原创 打开并读取文件

打开并读取文件file = open(r’C:\Users\Administrator\Desktop\Walden.txt’,‘r’)lines = file.readlines()words = []for line in lines:tmp_list = line.split()for word in tmp_list:对word_count字典进行排序,按照出现的次数(value)进行降序排序对words中每一个元素出现的个数把统计结果保存到字典中,字典的key是单词,value

2020-11-25 22:10:05 294

原创 词频统计

file = open(r'C:\Users\Administrator\Desktop\Walden.txt','r')lines = file.readlines()words = []for line in lines: tmp_list =line.split(" ") for word in tmp_list: words.append(word)word_count={}word_set = set(words)for word in word_set

2020-11-19 11:49:22 106

原创 抽取 点名

file =open('C:\\Users\\Administrator\\Desktop\\students.csv','r')lines = file.readlines()lines['1,张三\n', '2,李四\n', '3,王五\n']students = {}for line in lines: tmp_list=line.split(',') xuehao =tmp_list[0] xingming = tmp_list[1] stude

2020-11-19 10:35:40 72

原创 编写demo.py 和单词词频统计

filename = 'demo.py'with open(filename, 'r') as fp: lines = fp.readlines()maxLength = len(max(lines, key=len))lines = [line.rstrip().ljust(maxLength)+'#'+str(index)+'\n' for index, line in enumerate(lines)]with open(filename[:-3]+'_new.py

2020-11-15 19:33:16 164

原创 列表合并(无重复元素)

lst= eval(input('请输入列表lst:'))list2 =[1,2,3,4]for item in lst: if (item not in list2): list2.append(item)print(list2)请输入列表lst:4,5,6[1, 2, 3, 4, 5, 6]

2020-11-12 09:09:11 234

原创 猜数字

import randomcomputer=random.randint(1,100)while True: number=int(input("请输入100以内的整数:")) if(number>computer): print("大了") elif(number<computer): print("小了") else: print("恭喜你赢了") break请输入100以内的整数:50

2020-11-09 20:17:46 56

原创 约瑟夫环

def list1(n,k): #n代表总人数,k代表报数的数字 List = list(range(1,n+1)) index = 0 while List: temp = List.pop(0) index += 1 if index == k: index = 0 continue List.append(temp) if len(List)=

2020-11-08 21:42:11 57

原创 python 列表使用方法

创建一个列表list1 = ['a','b','c',4,5,6]列表中增加元素list1.append(8)list1['a', 'b', 'c', 4, 5, 6, 8]list1.insert(1,'f')list1['a', 'f', 'b', 'c', 4, 5, 6, 8]列表中修改元素list1=['a','b','c',4,5,6]print(list1)list1[0]="hello"print(list1)['a', 'b', 'c', 4, 5,

2020-11-05 10:00:34 164

原创 Untitled4

a=1a1b="hello world"b'hello world'all_in_list =[ 1, 'a word', print(1), [1,2],]1all_in_list[1]'a word'del all_in_list[1]all_in_list.append("hello world")all_in_list[0] = 5all_in_list[5, None, [1, 2], 'hello world

2020-11-04 22:18:14 104

原创 markdown笔记

1、编辑README文件一级标题:在文本下面加等于号,那么上方的文字就变成了大标题,等于号的个数无限制,但一定要大于0二级标题:在文本下面加下划线,那么上方的文本就变成了中标题,下划线个数无限制,中标题比大标题低一级1~6级标题:文本大小依次减小,以#号开头,多少个#号就是多少级标题,#号和标题名称要并排写#一级标题##二级标题###三级标题####四级标题#####五级标题######六级标题插入圆点符号:编辑的时候使用的是星号 *,星号后面要有一个空格,否则为普通星号列表一

2020-10-25 14:23:51 64

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除