自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(33)
  • 资源 (1)
  • 收藏
  • 关注

原创 python txt文件合并

#!/usr/bin/python# -*- coding: UTF-8 -*-import stringfp1 = open("a.txt")a = fp1.read()fp1.closefp2 = open("b.txt")b = fp2.read()fp2.closefp = open("c.txt","w")c = list(a + b)c.sort()s = ""s = s.join(c)fp.write(s)fp.close()有两个磁盘文件 a.txt

2020-12-03 19:38:34 403

原创 python 服务端与客户端

#!/usr/bin/python# -*- coding: UTF-8 -*-import sockets = socket.socket()host = socket.gethostname()port = 1235s.bind((host, port))s.listen(10)while True: c, addr = s.accept() print("链接地址:",addr) c.send(str.encode("1234")) c.close

2020-12-02 16:37:15 323

原创 python 链表运用

#!/usr/bin/python# -*- coding: UTF-8 -*-str = []n = int(input("输入数组个数:"))for i in range(n): i += 1 num = int(input("输入第%d个数:"%i)) str.append(num)print(str)

2020-12-01 19:31:35 300

原创 python 随机数生成

import randoma = int (random.uniform(1, 20))b = int (random.uniform(1, 20))while a > b: print("a > b, a = %d" % a ) breakelse: print("a <= b, b = %d" % b )随机数生成与判断

2020-11-30 19:53:08 166

原创 python 菱形编写

#!/usr/bin/python# -*- coding: UTF-8 -*-n = int(input("菱形的边长为:"))for i in range(1,n+1): for j in range(n - i): print(" ",end="") j += 1 for k in range(2 * i - 1): print("*",end="") k += 1 print ("\n") i +

2020-11-25 16:26:03 1951

原创 python python 判断回文数

#!/usr/bin/python# -*- coding: UTF-8 -*-#回文数r = int(input("请输入判断的数字:"))j = str(r)f = Truefor i in range(len(j)//2): if j[i] != j[-i - 1]: f = False breakif f: print("%d是一个回文数"% r)else: print("%d不是一个回文数"% r)// 可以直接整数

2020-11-24 17:57:39 665

原创 python 求s=a+aa+aaa+aaaa+aa...a的值

#!/usr/bin/python# -*- coding: UTF-8 -*-a = int(input("a:"))b = int(input("b:"))s = []t = 0for i in range(0 , b): t = t + a a = a * 10 s.append(t) # print(t)s = sum(s)print(s)

2020-11-19 19:59:49 3821

原创 python 统计字段的英文字母、空格、数字和其它字符的个数

#!/usr/bin/python# -*- coding: UTF-8 -*-import stringstr = input("输入判断的字符串:")z,k,n,o = 0,0,0,0for i in str: if i.isalpha(): z += 1 elif i.isspace(): k += 1 elif i.isdigit(): n += 1 else: o += 1print("

2020-11-18 15:21:04 872

原创 python 斐波那契数列(黄金分割数列)

def gold(n): if n == 0: return 0 if n == 1: return 1 return gold(n - 1)+gold(n - 2)i = int(input("斐波那契数列位数:"))print(gold(i))

2020-11-17 20:15:01 1054 1

原创 python 确定天数&比较大小

#确定为第几天year = int(input("请输入年:"))month = int(input("请输入月:"))day = int(input("请输入日:"))months = (0,31,59,90,120,151,181,212,243,273,304,334)if (year > 0)and(0 < month <= 12)and(0 < day <= 31): date = months[month - 1] date += da

2020-11-16 15:16:07 338

原创 python 数据判断&利润表计算

有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?#!/usr/bin/python# # -*- coding: UTF-8 -*-def Judge(num): while (num < 0) or (num > 9): print("输入错误,请输入大于等于0,小于10的整数") num = int(input("请再次输入:")) else: return numa = int(inp

2020-11-13 19:55:11 813

原创 python GUI编程tkinter

#!/usr/bin/python# # -*- coding: UTF-8 -*-import ModTkintertop = ModTkinter.Tk()top.mainloop()from ModTkinter import *r = Tk()list = ["HAZY","CC"]movie = ["boy","girl"]listb = Listbox(r)listc = Listbox(r)for i in list: listb.insert(0, i)f

2020-11-12 19:34:53 122

原创 python 多线程实现 threading

# encoding: utf-8#!/usr/bin/pythonimport threadingimport timeimport Queueexit = 0class testthread (threading.Thread): def __init__(self, id, name, counter): threading.Thread.__init__(self) self.threadID = id self.name =

2020-11-11 20:11:06 95

原创 python 操作mysql数据库(增删改查)

#!/usr/bin/python# -*- coding: UTF-8 -*-import pymysql# 打开数据库连接db = pymysql.connect("localhost","root","qq123456","TESTDB" )# 使用cursor()方法获取操作游标cursor = db.cursor()# # 如果数据表已经存在使用 execute() 方法删除表# cursor.execute("DROP TABLE IF EXISTS EMPLOYEE")

2020-11-09 16:41:16 173

原创 Python 正则表达式 findall、re.finditer、re.split

import ref = re.compile(r'\d+') #确定数字str1 = f.findall("ssdadadsad1221121sadsad23321321",11,111)print(str1)str2 = re.finditer(r"\d+","4545sadad545da464d56asa4d6sa4a")for match in str2: print(match.group())print(re.split('\W+', 'hazy,hazy,hazy.')

2020-11-06 16:48:03 444 1

原创 Python 正则表达式 re.sub与re.compile

#!/usr/bin/python# # -*- coding: UTF-8 -*-import renumber = "123-456-789 # test"num = re.sub(r'#.*$',"",number)print("电话:",num)num = re.sub(r"\D","",number)print("phone:",num)def double(math): s = int(math.group('s')) return str(s * 2)p

2020-11-05 20:32:31 1939 1

原创 Python 正则表达式 re.match与re.search

#!/usr/bin/python# # -*- coding: UTF-8 -*-import restr = "hazy is very happy"m = re.match(r'(.*) is (.*?) .*',str,re.M|re.I)s = re.search(r'(.*) is (.*?) .*',str,re.M|re.I)if m: print("测试 ",m.group()) print("测试 1", m.group(1)) print("

2020-11-04 20:09:42 198

原创 python 类(Class)初步使用 (下)

#!/usr/bin/python# # -*- coding: UTF-8 -*-class Attribute: public = 0 __private = 0 def variable(self): self.public += 1 self.__private += 1 print(self.__private)c = Attribute()c.variable()c.variable()print(c.publ

2020-11-03 15:01:22 246 1

原创 python 类(Class)初步使用 (中)

#!/usr/bin/python# # -*- coding: UTF-8 -*-class Parent: parentint = 100 def __init__(self): print("调用父类构造函数") def parentfar(self): print("调用父类方法") def setint(self,a): Parent.parentint = a def getint(self):

2020-11-02 20:51:10 174

原创 python 类(Class)初步使用 (上)

#!/usr/bin/python# # -*- coding: UTF-8 -*-class Population: "名单表" people = 0 def __init__(self,name,age): self.name = name self.age = age Population.people += 1 def displaypeople(self): print("总人数:%d"%Popu

2020-10-30 19:12:29 255

原创 python try/except与try/finally使用

#!/usr/bin/pythontry: create = open("test201029","w") create.write("hazy,hazy")except IOError: print("运行错误")else: print("运行成功") create.close()try: create = open("test201029","r") #只给读的权限 create.write("hazy,hazy")except IO

2020-10-29 20:37:29 319

原创 pytho os文件使用浅析

#!/usr/bin/python# # -*- coding: UTF-8 -*-import ostxt = open("test.txt","wb")print("文件名:",txt.name)print("是否已关闭:",txt.closed)print("访问模式",txt.mode)s = "hazy!\nhazy?\n"s = s.encode()txt.write(s)txt.closetxt = open("test.txt","r+")r = txt.rea

2020-10-28 20:26:31 115

原创 python 模块 import相关语句

def printtest( par ): print( "Hello : ", par) return新建一个def,演示调用#!/usr/bin/python# # -*- coding: UTF-8 -*-import supportsupport.printtest("hazy")# from test201022 import printlist## printlist(name = "cc",age = 27)from test201022 import

2020-10-27 21:01:42 129 1

原创 python 函数与部分使用示例

#!/usr/bin/python# # -*- coding: UTF-8 -*-def test(s): print(s) returntest("hazy")def changeint(a): a = 10 returnb = 2changeint(b)print(b)def printlist(name ,age = 27): #缺省参数 print("name: ", name) print("age: ",age) r

2020-10-22 19:48:40 615

原创 python 日期和时间(time&calendar)

#!/usr/bin/python# -*- coding: UTF-8 -*-def mian(): import time import calendar t = time.time() print("当前时间戳为:",t) l = time.localtime(time.time()) print("本地时间为:",l) b = time.asctime(time.localtime()) print("标准时间为:",b)

2020-10-21 19:29:51 149

原创 python 嵌套循环&break与continue区别

#!/usr/bin/python# -*- coding: UTF-8 -*-def main(): print("质数判断:") a = int(input("最小区间: ")) b = int(input("最大区间: ")) while (b < a): print("你输入的最小区间大于最大区间,请输入正确的范围!") break else: for x in range (a, b):

2020-10-20 20:31:51 951

原创 python while 判断使用

#!/usr/bin/python# # -*- coding: UTF-8 -*-def main(): print('while 循环:') a = int(input("请输入你要判断的数字:")) while (a < 0): print('%d是负数'% a) break while (a > 0): print('%d是正数' % a) break else:

2020-10-16 16:31:53 623

原创 python 变量类型&运算符说明

#!/usr/bin/python# coding=utf-8def main(): print("变量类型: 字符串、 列表、元组、字典") hazy = "Hazy Awesome " test = "Wonderful" list = ['a','b' ,'c',1, 2, 3] #列表可赋值 tuple = ('a','b' ,'c',1, 2, 3) #元组不可赋值 dictionaries = { } dictionaries['笑'

2020-10-16 10:31:25 72

原创 python 实心等边三角形&空心等边三角形

#!/usr/bin/python# # -*- coding: UTF-8 -*-def main(): print("实心三角形") solid = int(input("请输入边长为:")) for i in range(0, solid): for j in range(i, solid): print(" ", end='') for k in range(0, i + 1): prin

2020-10-14 20:28:18 1292 1

原创 python for...else用法

def forelse(): print("hazy算法\n100以内的质数:") for z in range(1,100): for s in range(2,z): if z%s == 0: # f = z/s # print( '%d 等于 %d * %d '%(z,s,f),end = '') break else:

2020-10-13 21:09:06 288

原创 python for循环小试&range()函数详解

#!/usr/bin/python# -*- coding: UTF-8 -*-def main(): food = ['苹果','香蕉','雪梨','李子'] for i in food: print('水果排序:'+i) print('数到3:') for i in range(1,4): print (i) print('hazy字母:') a = 'hazy' for i in range(len(a)):

2020-10-12 17:26:20 209

原创 python的print与input用法

#!/usr/bin/python# -*- coding: UTF-8 -*-def main(): print("你好,世界") print("这是Hazy\'的问候")#def foo(a,b): a = input("a=") b = input("b=") c = int(a)+int(b) print ('%s 加 %s 等于 %s'%(a,b,c)) if c<50: print("哈哈") eli

2020-10-02 11:43:53 500

原创 python与PyCharm安装环境

python下载链接:www.python.org这个没有什么难的,正常下载即可安装步骤个人觉得注意点,主要就是要勾选 “Add python” ,不然后续可能需要设置参数之类的PyCharm下载链接:官网下载 http://www.jetbrains.com/pycharm/download/#section=windows还有其他资源,需要的可以联系我获取这个也相对简单,只是后续有个解释器需要注意一点点击File,选择settings,选择project: python可能会提示以

2020-09-30 17:55:00 120

Linux I/O 原理和 Zero-copy 技术全面揭秘

两万字长文从虚拟内存、I/O 缓冲区,用户态&内核态以及 I/O 模式等等知识点全面而又详尽地剖析 Linux 系统的 I/O 底层原理,分析了 Linux 传统的 I/O 模式的弊端,进而引入 Linux Zero-copy 零拷贝技术的介绍和原理解析,将零拷贝技术和传统的 I/O 模式进行区分和对比,帮助读者理解 Linux 内核对 I/O 模块的优化改进思路。 全网最深度和详尽的 Linux I/O 及零拷贝技术的解析文章。

2020-11-18

空空如也

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

TA关注的人

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