Python 第4页
上课笔记以及平时作业记录

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不错哦1年前
0191

Python5.24练习

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

5.23_python_课堂练习

# UDP协议:面向消息的协议,通信时是不需要建立连接的,相对于tcp协议安全性不高,适用于多点通信,例如聊天软件,语音广播 # 案例:建立udp通信获取客户购物的数量 import socket sock = socke...
X.蔡徐坤的头像-北梦の博客X.蔡徐坤1年前
0311

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('等待客户...
珊瑚海的头像-北梦の博客珊瑚海1年前
0241

python-课堂笔记(5.10)

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

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不错哦1年前
0151

python–课堂

import re #1.正则表达式的两种定义方法 #(1)字符串方法: #匹配小写字母任意次 pattern = '[a-z]*'#正则表达式 print(re.match(pattern,'he123llo123'))#匹配0到第5个字符 print(re.match(pa...
iu不错哦的头像-北梦の博客iu不错哦1年前
0181

python课堂笔记

 
iu不错哦的头像-北梦の博客iu不错哦1年前
0181

Python_练习_24.4.7

练习1 def GetAge(age): try: if age <= 0: raise Exception('输入的年龄不符合要求') except ValueError: print('年龄必须大于0') raise GetAge(-1) 练习2 num_one = int(input('请输入被除...

Python_练习_24.3.29

选择题 try-except-else-finally练习 编写程序,按用户输人的半径计算圆的面积,若半径为负值则抛出异常