Python共36篇

Python上课笔记

编写列表推导式1、将一组数字列表[1,2,3,4,5,6,7,8],每个数字都平方并除以2.l1 = [1, 2, 3, 4, 5, 6, 7, 8] print([i * i / 2 for i in l1])2、将一组字符串列表['apple','banana','cherry'],...
北梦的头像-北梦の博客SVIP北梦2年前
12041

python_课堂作业_5.11

import re # 1.re.split()和字符串中的split()函数一样,用来切割字符串 # str.split()函数不支持正则表达式和多个切割符号 # re.split()函数可以通过正则表达式切割字符串,支持使用多个分隔...
X.蔡徐坤的头像-北梦の博客X.蔡徐坤11个月前
1212
python作业加注释6月6日-北梦の博客

python作业加注释6月6日

import pymysql my = pymysql.connect( host='127.0.0.1', user='root', password='123456789', db='world' ) cur = my.cursor() cur.execute('DROP TABLE IF EXISTS minyan;') sql = '''create...
koniaoer的头像-北梦の博客koniaoer10个月前
0361

python-课堂笔记-5.9

import re str1 = 'my naaaame is iu' #从开始位置去进行匹配 # print(re.match('my', str1).group(0)) # #search()是从整个字符串中查找和正则表达式匹配的字符串 # print(re.search('iu', str...
iu不错哦的头像-北梦の博客iu不错哦11个月前
0131

python-课堂笔记(5.10)

import re #1.re.findall()函数:查找字符串中所有匹配的子串,返回值类型是列表,如果未匹配到,则返回一个空列表而不是none # str1='qwertyuioppoiu0516q' # a=re.findall('i',str1) # print(a...
iu不错哦的头像-北梦の博客iu不错哦11个月前
0121

5.17练习python

1 import socket host = socket.gethostname() port=8081 serversock=socket.socket(socket.AF_INET,socket.SOCK_STREAM) serversock.bind((host,port)) serversock.listen(5) print('等待客户...
珊瑚海的头像-北梦の博客珊瑚海11个月前
0171

Python5.24练习

# 进程:正在进行的一个过程或者一个任务 # multiprocessing模块:用来开启子进程,并在子进程中执行任务 # 使用process类创建两个子进程 from multiprocessing import Process import os import...
珊瑚海的头像-北梦の博客珊瑚海11个月前
0211

python-课堂-5.30

#创建3个线程,每个线程包括2个子线程 import threading import time def process(): for i in range(2): time.sleep(2) print('线程的名称:{}'.format(threading.currentThread().name))#thre...
iu不错哦的头像-北梦の博客iu不错哦11个月前
0191

python_练习_mysql_24.6.6

import pymysql db = pymysql.connect( host='localhost', user='root', password='123456789', db='world' ) cursor = db.cursor() sql = '''CREATE TABLE zhangsan ( sno CHAR(10) PRIMARY KE...
北梦的头像-北梦の博客SVIP北梦10个月前
0181

python-pymysql

import pymysql #需求:在world数据库中,创建一张student表 #1.连接数据库 db=pymysql.connect(host='localhost',user='root',passwd='123456789',db='world') #创建一个游标对象 cursor=db.cu...
iu不错哦的头像-北梦の博客iu不错哦10个月前
0131