自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(23)
  • 资源 (2)
  • 问答 (3)
  • 收藏
  • 关注

原创 TypeError: __init__() takes 3 positional arguments but 4 were given

class Restaurant(): def __init__(self,restaurant_name,cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type self.number_served = 0 def describe_restaurant(self): return(self.restaura.

2020-09-06 11:38:01 37189 6

原创 TypeError: ‘int‘ object is not callable

class Restaurant(): def __init__(self,restaurant_name,cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type self.number_served = 0 def describe_restaurant(self): return(self.restaura.

2020-09-04 08:41:41 199

原创 #使用户输入来填充字典

responses = {}polling_active = Truewhile polling_active: #提示输入被调查者的名字和回答 name = input("\nWhat is your name") response = input("Which mountain would you like tu climb someday") #定义字典,并将答卷存在字典中 responses[name] = response #查看是否还有人要.

2020-08-16 21:25:49 636

原创 用while循环来处理列表和字典

for循环不能修改列表,否则将导致python难以跟踪其中的元素。要在遍历的同事对其进行修改,可还是用while;#首先创建一个待验证的用户列表,和一个用于存放已验证用户的空列表unconfirmed_users = ['alice','brain','candace']confirmed_users = []#验证每个用户,直到没有未验证用户为止;将每个经过验证的列表都移到已验证的用户列表中;while unconfirmed_users: current_user = unco.

2020-08-16 20:43:59 808

原创 统计学重要知识点(重点内容)学习——概率与概率分布

离散型随机变量及其分布: 离散型随机变量:如果随机变量X的所有取值都可以组个列举出来; 期望值:各可能值Xi与其对应概率pi的乘积之和称为随机变量X的期望值;二项式分布:n个相同实验就2个结果 期望值μ=E(X)= XiPi 方差:随机变量与其数学期望值的理查的平均水平,可反应变异程度或离散程度; 泊松分布:一定时间范围内时间出现的概率;当p<=0.25,n>20,np<=5时近似二项分布...

2020-08-16 19:53:29 513

原创 python AttributeError: ‘list‘ object has no attribute ‘sorted‘

my_frind = ['曹大鹏','王姐','李妍']a = ['ab','fg','cg']b = a.sorted()print(b)AttributeError: 'list' object has no attribute 'sorted'sort()是方法,sorted()是函数,方法是调用,函数进行数据传递a = ['ab','fg','cg']print(sorted(a))...

2020-08-03 23:14:17 623

原创 TypeError: list indices must be integers or slices, not str 原因及解决方法

my_frind = ['曹大鹏','王姐','李妍']message = "hi,"+ my_frind[0] + "周末一起来吃晚饭啊"print("hi,"+ my_frind[0]+"周末一起吃饭啊")#print(message)print("王姐","没时间不能来了")del my_frind['王姐']my_frind.insert(1,"君君")print(my_frind)TypeError: list indices must be integers ...

2020-08-03 22:07:37 3682

原创 python的mysql数据查询及报错AttributeError: 'Connection' object has no attribute 'curson'

import pymysql#创建连接con = pymysql.connect(host='localhost',user='root',password='123456',port=3306,database='zhy')#创建游标对象cur = con.curson()#编写查询的sql语句sql = 'select * from t_student'try: cur...

2020-02-17 10:02:14 8922 1

原创 python的mysql数据库创建表及插入数据

#创建表#导入pymysqlimport pymysql#创建链接con = pymysql.connect(host='localhost',user='root',password='123456',database='zhy',port=3306)#创建游标对象cur = con.cursor()#编写创建表的sqlsql = """ create table ...

2020-02-17 09:15:17 2390

原创 python使用sqlite3模块删除数据报错parameters are of unsupported type

import sqlite3#链接数据库con = sqlite3.connect('C:\python_learn\DBA\SQLite3demo\sqlite3demo.db')#创建游标对象cur = con.cursor()#编写sql语句sql = "delete from t_person where pno = ?"#执行sqltry: cur.execut...

2020-02-15 09:58:59 2067

原创 python中sqlite3模块查询数据一条或多条

#导入模块import sqlite3#创建链接con = sqlite3.connect('C:\python_learn\DBA\SQLite3demo\sqlite3demo.db')#创建游标对象cur = con.cursor()#编写sql语句sql = "select * from t_person "#执行语句try: cur.execute(sql)...

2020-02-15 09:27:44 2782

原创 python数据库表sqlite3模块插入数据

import sqlite3#连接数据库con = sqlite3.connect('C:\python_learn\DBA\SQLite3demo\sqlite3demo.db')#创建游标cur = con.cursor()#编写sql语句sql = 'insert into t_person(pname,age) values(?,?)' #括号中是插入的字段,用逗号隔...

2020-02-14 12:53:49 1871

原创 python如何使用sqlite3模块创建数据库表

'''1.导入sqlite3模块2.创建连接sqlite3.connect()3.创建游标对象4.编写创建表的sql的语句5.执行sql(包括异常语句try)6.关闭连接'''import sqlite3#创建连接con = sqlite3.connect('C:\python_learn\DBA\SQLite3demo\sqlite3demo.db')print(con...

2020-02-14 12:20:23 2928

原创 pygame模块在pycharm的安装

一、进入pycharm,在file中找到"Settings"点击进入;二、找到Project Interpreter 选项:右侧为已安装的模块。点击最右侧的“+”新增模块三、搜索Pygame点击左下角的安装按钮【install Package】进行安装;...

2020-02-14 09:58:21 229 1

原创 python使用递归计算n的阶乘(s!=5*4*3*2*1)

#coding= utf-8#使用递归计算n的阶乘(s!=5*4*3*2*1)def factorial(a): if n==1: return n else: return n*factorial(n-1)print(factorial(5))#打印结果120

2020-02-08 22:13:04 3861

原创 python读写csv文件,使用csv.reader()方法及csv.writer()方法

python读写csv文件,使用csv.reader()方法及csv.writer()方法import csvwith open(r"C:\郑宏宇\python_learn\c.csv","r") as f: a_csv = csv.reader(f) for row in a_csv: print(row)with open(r"C:\郑宏宇\pyt...

2020-02-08 08:06:34 7027

原创 python使用pickle实现序列化和反序列化

#使用pickle实现序列和反序列化import picklea1 = "中国"a2 = 12345a3 = [10,20,30,40,50]with open(r"C:\郑宏宇\python_learn\t.txt","wb")as f: pickle.dump(a1,f) pickle.dump(a2,f) pickle.dump(a3,f)with...

2020-02-08 07:17:49 281

原创 python读文件集中方式以及编码错误UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 12: illegal mu

s = ["您好\n","非常好\n","很高兴认识你\n"]with open(r"C:\郑宏宇\python_learn\t.txt","w",encoding = "utf-8") as f: f.writelines(s)#读取一个文件前4个字符with open(r"C:\郑宏宇\python_learn\t.txt","r",encoding = "utf-8") ...

2020-02-06 22:01:03 238

原创 python类组合

class A2: def say_a2(self): print("a2,a2,a2")class B2: def __init__(self,a): self.a = aa2 = A2()b2 = B2(a2)b2.a.say_a2()采用组合的方法同样可以实现类继承;...

2020-02-03 16:37:08 98

原创 python多态及isinstance

class study(): def eat(self): print("饿了,吃饭了")class Chinese(Man): def study(self): print("学习汉语")class English(): def study(self): print("学习英语")class Indian(Man...

2020-02-03 12:40:28 148

原创 python构造函数

class Employee: def __init__(self,name,age): self.name = name self.__age = age print("您好") def __work(self): print("疫情严重,在家学习") print("年龄:{0}".format(...

2020-02-03 08:36:28 285

原创 python,私有属性运行报错; object has no attribute

python对于类的成员没有严格的访问控制限制,这与其他面向对象的语言有区别。关于私有属性和私有方法,有如下要点:1)通常我们约定,两个下划线开头的属性是私有的,其他是公共的;2)类内部可以访问私有属性(方法)3)类外部不能直接访问私有属性(方法)4)类外部可以通过“_雷鸣__私有属性(方法)”访问私有属性(方法)class Employee: def __init__(s...

2020-02-01 17:15:55 81288 4

原创 python构造函数__init__提示:Student() takes no arguments

class Student: def _init_(self,name,score): #应该是__init__ self.name = name self.score = score def say_score(self): print("{0}的分数是:{1}".format(self.name,self.score))...

2020-01-31 19:18:58 473

微软文档模板

比较全的文档,是微软内部使用的开发刮泥文档。

2012-08-15

有效测试的50条建议

软件测试初学者比较适合的一本电子书。通读本书会有进步。

2011-05-09

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

TA关注的人

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