自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 python连接mysql问题

#!/usr/bin/env python #coding:utf-8 import mysql.connector #jdbc=mysql.connector.connect(host='localhost',user='root',password='123456',database='student',port=3306,charset='utf8') str={'host':'localh...

2018-03-24 16:24:13 248

原创 对数据库、数据库表、及表中数据的基本操作

1、启动数据库:net start mysql2、进入数据库:mysql -h localhost(进入本地数据库)-u root -p3、创建数据库:create database student;4、展示数据库:show databases ;5、使用数据库:use student;6、创建数据库表:create table student                           ...

2018-03-24 09:17:24 3261 1

原创 python之顺序表增删查实现

class shunxubiao: def __init__(self,length):#length表示顺序表的长度,决定此顺序表最多存储多少元素 self.length=length self.data=[] #data表示顺序表内容 self.biao=-1 #元素下标 def weikong(self):#判断 这个顺序表...

2018-03-23 10:11:01 1102 1

原创 StringIO中getvalue和readline方法

from io import StringIO f=StringIO('qihang') f.write('xingxing') print(f.read())此时输出是空的from io import StringIO f=StringIO('qihang') print(f.read())此时可以输出qihangfrom io import StringIO f=StringIO() f.wr...

2018-03-20 16:14:28 2425 5

原创 map疑问??

>>> from functools import reduce >>> def fn(x, y): ... return x * 10 + y ... >>> def char2num(s): ... digits = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': ...

2018-03-14 17:55:14 258

原创 用python实现汉诺塔

#递归函数是在函数内部调用自己函数本身,叫做递归函数。 def hannuota(n): if n==1: return 1 elif n==2: return 3 else: return (2*hannuota(n-1)+1) print(hannuota(7))...

2018-03-14 12:24:15 218

原创 输入某年某月某日求出该日期在本日的第几天

#求输入某年某月某日求出该日期在本日的第几天 year=int(input('qingshuru:')) month=int(input('qingshuru:')) day=int(input('qingshuru:')) months=(0,31,59,90,120,151,181,212,243,273,304,334) if (month>12) or (month<0): ...

2018-03-14 12:23:40 1577

原创 text2出现的问题

1、 name 'raw_input' is not defined解决方式:python3.0中将raw_input改为input2、IndexError: list index out of range解决方式:list下标超限代码:!/usr/bin/python # -*- coding: UTF-8 -*- lirun=int(raw_input('净利润:')) chanzhi=[10...

2018-03-14 08:48:22 240

原创 为什么self._name没有被private呢

class xianzhi: def __init__(self,name,age): self._name=name self.age=age cla=xianzhi('qihang',23) print(cla.age) print(cla._name) 原来是_需要两个下划线__不是一个_

2018-03-13 15:28:54 380

原创 _slots_函数学习使用

_slots_函数可以控制类实例属性,若继承父类,_slots_对子类不起作用 class slots(object): __slots__ = ('name','age') s=slots() s.name="qihang" s.age=23 s.zhiye="chengxuyuan" #系统会报错误,因为没有吧‘zhiye’放在_slots_函数里面 class slots(obje...

2018-03-13 15:23:18 338

原创 python出现Errno 2] No such file or directory错误

f=open('C:\111.txt','r')原因:python转义字符为/,所以出现找不到文件错误,应该为f=open('c:/111.txt','r')

2018-03-13 14:49:28 44139 2

原创 MethodType方法学习使用心得

不使用MethodType时setnaeme直接定义在类中,每个实例都有name属性并且都是自己独有的,而使用MethodType时等于setname这个方法是独立的,只是与类绑定在了一块,类的实例也也没有name属性,name属性是setname方法的,不是类的实例拥有的。代码如下:#未用MethodType方法,直接在类内部定义 class hello: def __init__(se...

2018-03-13 14:45:35 375

空空如也

空空如也

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

TA关注的人

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