上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 17 下一页
摘要: ''' 11. 编写程序,判断一个数是不是素数,是则输出“Yes”,不是输出“No”.(while循环) ''' num = int(input()) i = 2 flag = True while i < num: if num % i ==0: flag = False i += 1 if fl 阅读全文
posted @ 2020-05-30 12:31 CodeYaSuo 阅读(268) 评论(0) 推荐(0) 编辑
摘要: ''' 1. 编写程序,功能是把输入的字符串的大写字母变成小写字母, 小写字母变成大写字母,非字母的字符不作变换。输出变换后的结果 ''' string = input() s = '' for str in string: if 'a' <= str <= 'z': s += str.upper( 阅读全文
posted @ 2020-05-30 12:30 CodeYaSuo 阅读(711) 评论(0) 推荐(0) 编辑
摘要: ''' 6. 一元二次方程:ax2+bx+c=0 (a ╪ 0) 【输入形式】输入a、b和c的值(有理数) 【输出形式】输出x的两个值,或者No(即没有有理数的解) ''' import math a = int(input()) b = int(input()) c = int(input()) 阅读全文
posted @ 2020-05-30 12:29 CodeYaSuo 阅读(526) 评论(0) 推荐(0) 编辑
摘要: tom 85 90 jerry 95 80 lucy 80 90 rose 88 90 jay 76 75 summer 87 85 horry 84 80 dic = {} with open('score.txt','r') as f: lines = f.readlines() f.close 阅读全文
posted @ 2020-05-30 08:59 CodeYaSuo 阅读(156) 评论(0) 推荐(0) 编辑
摘要: import pandas as pd def get_data(): q1 = [] q2 = [] p1 = input("list 1:") p2 = input("list 2:") q1=p1.split(',') q2=p2.split(',') for i,j in zip(range 阅读全文
posted @ 2020-05-29 22:26 CodeYaSuo 阅读(1516) 评论(0) 推荐(0) 编辑
摘要: def dollar(n): global story_money money = [] for i in range(10): if 2**(i+1) > story_money-sum(money): money.append(story_money-2**i+1) break money.ap 阅读全文
posted @ 2020-05-29 19:58 CodeYaSuo 阅读(236) 评论(0) 推荐(0) 编辑
摘要: 将 NaN 替换成某一数值 使用 fillna dataframe.fillna(value = 'xxx',inplace=True) 删除某一个值 使用 drop dataframe.drop(10,inplace=True) 交换两行的值 if m != n: temp = np.copy(d 阅读全文
posted @ 2020-05-29 18:26 CodeYaSuo 阅读(133) 评论(0) 推荐(0) 编辑
摘要: file = open('abc.txt','r',encoding='utf-8') file = open('abc.txt','w',encoding='utf-8') 'w' 写入模式 会清空掉文件,然后再写入 不想完全覆盖掉原文件的话,使用'a' 关键字with,with open(xxx 阅读全文
posted @ 2020-05-29 12:06 CodeYaSuo 阅读(113) 评论(0) 推荐(0) 编辑
摘要: import random ganran = float(input("请输入感染概率")) is_person_ganran = False # 人是否感染了 person_ganran = random.randint(0,100) if person_ganran /100 < ganran: 阅读全文
posted @ 2020-05-29 10:28 CodeYaSuo 阅读(83) 评论(0) 推荐(0) 编辑
摘要: python 版本 3.6 不要使用 3.7 和 3.8 否则导致安装失败 tensorflow 使用 1.12.0 keras 使用 2.2.4 版本 pip install 包名 -i http://pypi.douban.com/simple/ --trusted-host pypi.doub 阅读全文
posted @ 2020-05-28 22:48 CodeYaSuo 阅读(367) 评论(0) 推荐(0) 编辑
摘要: 当获取到的数据不存在时,可以通过设置一个 len( data ) 设置一个长度 ,过滤掉 不到长度的数据 设置一个布尔类型的全局变量 当访问到时 设置为 True 如果没有访问到,则设置为 False根据全局变量的值,判断是否继续进行访问 2020-05-28 阅读全文
posted @ 2020-05-28 21:05 CodeYaSuo 阅读(99) 评论(0) 推荐(0) 编辑
摘要: os.chdir(r"C:\Users\47311\Desktop\code\") #修改为自己文件路径 data = pd.read_excel(r"公司公告2020.xlsx")[:-1] #读入数据,并删除最后一行(最后一行为空值) 读取的数据在 chdir 之下 存在多个数据时,使用字符串类 阅读全文
posted @ 2020-05-28 13:18 CodeYaSuo 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 在 templates 中创建对应文件名的 html 文件 (404.html) 注: 开发者服务器发生变更是因为 python 代码发生变化 如果 html 文件发生变化,服务器不会进行重启 需要自己手动修改 注意就近原则,如果有重复名字,先用最近的 阅读全文
posted @ 2020-05-28 12:40 CodeYaSuo 阅读(95) 评论(0) 推荐(0) 编辑
摘要: ''' 1. 编写程序实现:计算并输出标准输入的三个数中绝对值最小的数。 ''' #计算并输出标准输入的三个数中绝对值最小的数。 import math num1 = int(input()) num2 = int(input()) num3 = int(input()) num_list = (n 阅读全文
posted @ 2020-05-28 10:15 CodeYaSuo 阅读(517) 评论(0) 推荐(0) 编辑
摘要: score.txt 文件内容 李彦宏 男 英语 80 李彦宏 男 电子技术基础 75 李彦宏 男 Python程序设计 88 马云 男 英语 62 马云 男 电子技术基础 63 马云 男 Python程序设计 68 黄蓉 女 英语 90 黄蓉 女 电子技术基础 80 黄蓉 女 Python程序设计 阅读全文
posted @ 2020-05-28 10:13 CodeYaSuo 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 一闪而过可能是程序出错,导致的 .py 文件导入的文件,使用相对路径 在导包成 exe 文件时 将使用到的文件放入到 同一文件夹内 即可运行 另外,程序一闪而过 可以考虑使用 time.sleep(30) 方法 2020-05-27 阅读全文
posted @ 2020-05-27 22:05 CodeYaSuo 阅读(157) 评论(0) 推荐(0) 编辑
摘要: import re pattern = '\d+?\.\d+' s = "[Decimal('90.900000')]" s2 = "[Decimal('75.900000'),Decimal('57.280000')]" [print(i,end = " ") for i in re.findal 阅读全文
posted @ 2020-05-27 12:16 CodeYaSuo 阅读(224) 评论(0) 推荐(0) 编辑
摘要: import random def no_change(times): glass_ball = 0 diamond = 0 times2=times while times>0: drawers={'drawer1': False, 'drawer2': False, 'drawer3': Fal 阅读全文
posted @ 2020-05-27 11:03 CodeYaSuo 阅读(153) 评论(0) 推荐(0) 编辑
摘要: import numpy as np import pandas as pd import matplotlib.pyplot as plt cqlq=pd.read_csv("cqlq.txt",sep="\s+",encoding="gbk") dxnt=pd.read_csv("dxnt.tx 阅读全文
posted @ 2020-05-27 10:58 CodeYaSuo 阅读(173) 评论(0) 推荐(0) 编辑
摘要: def predict(train_samples,X): #描述属性分别用数字代替 #年龄: <=30:0, 30~40:1, <40:2 #收入:‘低’:0,'中':1,'高':2 #是否学生:‘是’:1,'否':1 #信誉: '中':0,'优':1 #购买属性用数字代替 #购买电脑 :‘是’: 阅读全文
posted @ 2020-05-27 10:56 CodeYaSuo 阅读(134) 评论(0) 推荐(0) 编辑
摘要: import sqlite3 conn = sqlite3.connect('studentsdb.db') # 连接数据库 cursor = conn.cursor( ) # 创建数据表 def createDatabase(): '''创建一个数据表''' sql = 'create table 阅读全文
posted @ 2020-05-27 10:54 CodeYaSuo 阅读(435) 评论(0) 推荐(0) 编辑
摘要: import pandas as pd import numpy as np import matplotlib.pyplot as plt cqlq = pd.read_excel("cqlq.xls",sep='\s+') dxnt = pd.read_excel("dxnt.xls",sep= 阅读全文
posted @ 2020-05-27 10:53 CodeYaSuo 阅读(127) 评论(0) 推荐(0) 编辑
摘要: c = [[0, 0, 0, 0], [0, 2, 4, 4], [0, 4, 1, 2], [0, 4, 2, 2]] o = [0, 8, 14, 10] d = [0, 8, 14, 10] am = [0, 1, 1, 1] ampl1 = [0, 0, 0, 0] bm = [0, 0, 阅读全文
posted @ 2020-05-26 20:54 CodeYaSuo 阅读(900) 评论(0) 推荐(0) 编辑
摘要: import numpy as np import pandas as pd import matplotlib.pyplot as plt cqlq=pd.read_csv("cqlq.txt",sep="\s+",encoding="gbk") dxnt=pd.read_csv("dxnt.tx 阅读全文
posted @ 2020-05-26 20:52 CodeYaSuo 阅读(313) 评论(0) 推荐(0) 编辑
摘要: inf = float('inf') 此时的 inf 就是无穷了 2020-05-26 阅读全文
posted @ 2020-05-26 20:49 CodeYaSuo 阅读(591) 评论(0) 推荐(0) 编辑
摘要: import jieba strings = '我工作在安徽的安徽师范大学,这个大学很美丽,在芜湖' # print(dir(jieba)) dic_strings = {} lst_strings = jieba.lcut(strings) for ci in lst_strings: # 对得到 阅读全文
posted @ 2020-05-25 17:00 CodeYaSuo 阅读(122) 评论(0) 推荐(0) 编辑
摘要: for i in range(1000,2201): if i % 7 == 0 and i % 5 != 0: print(i,end = " ") def func(num): if num == 0: return 1 return num * func(num - 1) print(func 阅读全文
posted @ 2020-05-25 16:26 CodeYaSuo 阅读(155) 评论(0) 推荐(0) 编辑
摘要: from turtle import * def go_to(x, y): up() goto(x, y) down() def head(x, y, r): go_to(x, y) speed(1) circle(r) leg(x, y) def leg(x, y): right(90) forw 阅读全文
posted @ 2020-05-24 21:32 CodeYaSuo 阅读(553) 评论(0) 推荐(0) 编辑
摘要: ''' 开始,你可以随意选择一个抽屉,在开启它之前, 主持人会开启另外一个抽屉,露出抽屉里的玻璃球。 这时,主持人会给你一次更换自己选择的机会。 请自己认真分析一下“不换选择能有更高的几率获得钻石, 还是换选择能有更高的几率获得钻石?或几率没有发生变化?”写出你分析的思路和结果。 设法编写pytho 阅读全文
posted @ 2020-05-24 20:00 CodeYaSuo 阅读(278) 评论(0) 推荐(0) 编辑
摘要: lst = ['中雨','雷阵雨','中到大雨','阴','多云','晴','中雨'] dic = {} for i in lst: if i not in dic: dic[i] = lst.count(i) print(dic) 2020-05-24 阅读全文
posted @ 2020-05-24 17:09 CodeYaSuo 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 3D图形 导包 import numpy as np import matplotlib.pyplot as plt #3d图形必须的 from mpl_toolkits.mplot3d.axes3d import Axes3D %matplotlib inline 生成数据 #系数,由X,Y生成Z 阅读全文
posted @ 2020-05-24 14:55 CodeYaSuo 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 四图 直方图 【直方图的参数只有一个x!!!不像条形图需要传入x,y】 hist()的参数 bins 可以是一个bin数量的整数值,也可以是表示bin的一个序列。默认值为10 normed 如果值为True,直方图的值将进行归一化处理,形成概率密度,默认值为False color 指定直方图的颜色。 阅读全文
posted @ 2020-05-24 14:29 CodeYaSuo 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 设置plot的风格和样式 点和线的样式 颜色 参数color或c 五种定义颜色值的方式 别名 color='r' 合法的HTML颜色名 color = 'red' HTML十六进制字符串 color = '#eeefff' 归一化到[0, 1]的RGB元组 color = (0.3, 0.3, 0. 阅读全文
posted @ 2020-05-24 14:20 CodeYaSuo 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 灰度化处理就是将一幅色彩图像转化为灰度图像的过程。彩色图像分为R,G,B三个分量,分别显示出红绿蓝等各种颜色,灰度化就是使彩色的R,G,B分量相等的过程。灰度值大的像素点比较亮(像素值最大为255,为白色),反之比较暗(像素最下为0,为黑色)。 图像灰度化的算法主要有以下3种: data2 = da 阅读全文
posted @ 2020-05-24 14:11 CodeYaSuo 阅读(194) 评论(0) 推荐(0) 编辑
摘要: fruit = [] def menu(): print( ''' ********************水果超市******************** (面向对象,面向过程) 1. 查询全部水果 2. 查询指定名称的水果 3. 增加水果(增加到数据库) 4. 修改水果数量或者价格 5. 删除水 阅读全文
posted @ 2020-05-24 12:27 CodeYaSuo 阅读(424) 评论(0) 推荐(0) 编辑
摘要: def numRoot(num): '''定义数根函数''' if len(num) == 1: return int(num) else: nums = [] for i in range(len(num)): # 对字符串进行遍历 nums.append(int(num[i])) if sum( 阅读全文
posted @ 2020-05-23 18:06 CodeYaSuo 阅读(164) 评论(0) 推荐(0) 编辑
摘要: '''定义函数,给定一个列表作为函数参数,将列表中的非数字字符去除。''' class list: def __init__(self,alist): self.alist=alist def remove_str(self): a="" for i in self.alist: b=str(i) 阅读全文
posted @ 2020-05-23 16:39 CodeYaSuo 阅读(895) 评论(0) 推荐(0) 编辑
摘要: import re # 导入正则表达式模块 import os # 导入操作系统模块 filename = "students.txt" # 定义保存学生信息的文件名 def menu(): # 输出菜单 print(''' ╔———————学生信息管理系统————————╗ │ │ │ 功能菜单 阅读全文
posted @ 2020-05-23 08:50 CodeYaSuo 阅读(327) 评论(0) 推荐(0) 编辑
摘要: import math def f(n): if isinstance(n,int): for i in range(round(math.sqrt(n))): for j in range(round(math.sqrt(n))): for k in range(round(math.sqrt(n 阅读全文
posted @ 2020-05-22 22:49 CodeYaSuo 阅读(132) 评论(0) 推荐(0) 编辑
摘要: for i in range(1000,10000): t=str(i) if pow(eval(t[0]),4)+pow(eval(t[1]),4)+pow(eval(t[2]),4)+pow(eval(t[3]),4) == i: print(i) 2020-05-22 阅读全文
posted @ 2020-05-22 22:09 CodeYaSuo 阅读(809) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 17 下一页