就业DAY6_web服务器_正则表达式 # 匹配变量名是否符合要求import redef main(): names = ["name1", "_name", "2_name", "__name__", "___", "name!"] for name in names: ret = re.match("^[a-zA-Z_][a...
就业DAY5_多任务_进程,进程池,队列 import timeimport multiprocessingdef sing(): """"唱歌 5秒钟""" for i in range(5): print("----正在唱歌----") time.sleep(1)def dance(): """跳舞 子线程""" for ...
就业DAY4_多任务_线程 import timeimport threading# 定义一个全局变量def test(temp): temp.append(33) print("---in test g_num=%s" % str(temp))def test2(temp): print("---in test2 g_num=%s" % st...
基础DAY16-飞机大战-精灵 import pygameclass GameSprite(pygame.sprite.Sprite): """飞机大战游戏精灵""" def __init__(self, image_name, speed = 1): # 调用父类的初始化方法 super().__init__() ...
基础DAY14-飞机大战-绘制图像 import pygamepygame.init()# 创建游戏窗口screen = pygame.display.set_mode((480, 700))# 加载backgroud.png创建背景bg = pygame.image.load("./images/background.png")# 将背景绘制在屏幕的(0,0)位置screen.bl...
基础DAY14-飞机大战-创建游戏主窗口 python -m pygame.examples.aliensimport pygamepygame.init()# 编写邮箱代码print("游戏代码")pygame.quit()初始化和退出import pygame# 定义hero_rect矩形描述英雄的位置和大小hero_rect = pygame...
python3 pip ipython 安装 1.安装Python3.6安装准备mkdir /usr/local/python3wget --no-check-certificate https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgztar -xzvf Python-3.6.0.tgzcd Python-3.6.0编译安装./configure...
基础DAY13-文本编码 python2 字符串# *-* coding:utf8 *-*# 引号前面的u告诉解释器这是一个utf8编码格式的字符串hello_str = u"hello世界"print(hello_str)for c in hello_str: print(c)转载于:https://www.cnblogs.com/joycezhou/p/11420142.html...
就业DAY7_web服务器_tcp三次握手四次挥手,返回浏览器需要的页面http服务器 import socketdef servece_client(new_socket): """为这个客户端返回数据""" # 1 接收浏览器发送过来的请求,即http请求 # GET / HTTP/1.1 # ... request = new_socket.recv(1024...
基础DAY13-文件 文本文件二进制文件# 打开文件file = open("README")# 读取文件text = file.read()print(text)# 关闭文件file.close()读取文件# 打开文件try: file = open("README")except Exception as result:...
就业DAY7_web服务器_http协议 import socketdef servece_client(new_socket): """为这个客户端返回数据""" # 1 接收浏览器发送过来的请求,即http请求 # GET / HTTP/1.1 # ... request = new_socket.recv(1024) print(request)...
就业DAY5_多任务_协程 判断是否可迭代In [4]: from collections import IterableIn [6]: isinstance(123,Iterable) Out[6]: FalseIn [11]: isinstance((123),Iterable) ...
基础DAY12-包 from . import send_messagefrom . import receive_message__init__def receive(): return "这是来自100xx的短信"receive_messagedef send(text): print("正在发送%s" % text)s...
就业DAY3_多任务_线程 import threadingimport timedef test1(): for i in range(5): print("---test1----%d" % i) time.sleep(1) # 如果创建Thread时执行的函数,运行结束,意味着这个子线程结束了def test2...
基础DAY11-模块import import hm_01_测试模块1import hm_02_测试模块2hm_01_测试模块1.say_hello()dog = hm_01_测试模块1.Dog()print(dog)hm_02_测试模块2.say_hello()cat = hm_02_测试模块2.Cat()print(cat)print(hm_01_测试模块1.titl...
基础DAY10-异常 捕获异常try: ..except: ...try: num = int(input("请输入整数:"))except: print("请输入整数")异常提示捕获未知错误try: # 提示用户输入一个整数 num = int(input("请输入一个整数")) # 使用 8 除以用户输入的...
就业DAY1_网络编程 知名端口 0-1023动态端口 1024-65535import socketdef main(): # 创建一个udp套接字 udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) while True: # 从键盘获取数据 s...
基础DAY10-单例 class MusicPlayer(object): # * 元组 ** 字典 def __new__(cls, *args, **kwargs): # 使用类名创建对象,new方法会被自动调用 print("创建对象,分配空间") # 2 为对象分配空间 instranc...
基础DAY15-飞机大战-监听事件 import pygamepygame.init()# 创建游戏窗口screen = pygame.display.set_mode((480, 700))# 加载backgroud.png创建背景bg = pygame.image.load("./images/background.png")# 将背景绘制在屏幕的(0,0)位置screen....