08 2019 档案
摘要:import socketdef main(): # 创建套接字 tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # 获取服务器的ip port dest_addr = input("请输入服务器的ip:") dest_port = int(input("请输入服务器的port:")) # 链接服务器 tcp_socke
阅读全文
posted @ 2019-08-31 20:52
才华配得上梦想
摘要:from socket import * import socket def main(): # 创建tcp套接字 tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # 链接服务器 # tcp_socket.connect(("10.6.25.79", 8080)) server_ip = input("请输入需要链接服务
阅读全文
posted @ 2019-08-31 19:55
才华配得上梦想
摘要:import socket def send_msg(udp_socket): """发送消息""" # 发数据 # 获取要发送的内容 send_data = input("请输入传递的信息") dest_ip = input("请输入对方的ip;") dest_port = int(input("请输入对方的port:")) udp_socket.sendto(send_data.encode(
阅读全文
posted @ 2019-08-31 18:03
才华配得上梦想
摘要:import pygame class GameSprite(pygame.sprite.Sprite): """飞机大战游戏精灵""" def __init__(self, image_name, speed = 1): # 调用父类的初始化方法 super().__init__() # 定义对象
阅读全文
posted @ 2019-08-30 15:26
才华配得上梦想
摘要:import pygame pygame.init() # 创建游戏窗口 screen = pygame.display.set_mode((480, 700)) # 加载backgroud.png创建背景 bg = pygame.image.load("./images/background.pn
阅读全文
posted @ 2019-08-29 08:24
才华配得上梦想
摘要:import pygame pygame.init() # 创建游戏窗口 screen = pygame.display.set_mode((480, 700)) # 加载backgroud.png创建背景 bg = pygame.image.load("./images/background.pn
阅读全文
posted @ 2019-08-28 12:21
才华配得上梦想
摘要:python -m pygame.examples.aliens import pygame pygame.init() # 编写邮箱代码 print("游戏代码") pygame.quit() import pygame # 定义hero_rect矩形描述英雄的位置和大小 hero_rect =
阅读全文
posted @ 2019-08-27 21:17
才华配得上梦想
摘要:1.安装Python3.6 安装准备 编译安装 将默认Python修改为Python3.6,并为其创建软连接 修改yum使用的原python的配置文件 2.安装pip3 安装pip依赖库 如果安装上述依赖库出现以下报错:Delta RPMs disabled because /usr/bin/app
阅读全文
posted @ 2019-08-27 19:28
才华配得上梦想
摘要:文本文件 二进制文件 # 打开文件 file = open("README") # 读取文件 text = file.read() print(text) # 关闭文件 file.close() # 打开文件 try: file = open("README") except Exception a
阅读全文
posted @ 2019-08-27 08:48
才华配得上梦想
摘要:from distutils.core import setup setup(name=“hm_message”, # 包名version=“1.0”, # 版本description=“itheima’s 发送和接收消息模块”, # 描述信息long_description=“完整的发送和接收消息
阅读全文
posted @ 2019-08-27 07:58
才华配得上梦想
摘要:from . import send_message from . import receive_message def receive(): return "这是来自100xx的短信" def send(text): print("正在发送%s" % text) import hm_message
阅读全文
posted @ 2019-08-26 19:47
才华配得上梦想
摘要:import hm_01_测试模块1 import hm_02_测试模块2 hm_01_测试模块1.say_hello() dog = hm_01_测试模块1.Dog() print(dog) hm_02_测试模块2.say_hello() cat = hm_02_测试模块2.Cat() print
阅读全文
posted @ 2019-08-23 21:33
才华配得上梦想
摘要:def demo1(): return int(input("请输入一个整数")) def demo2(): return demo1() # 利用异常的传递性 ,在主程序捕获异常 try: print(demo2()) except Exception as result: print("未知错误
阅读全文
posted @ 2019-08-23 20:50
才华配得上梦想
摘要:捕获异常 try: .. except: ... try: num = int(input("请输入整数:")) except: print("请输入整数") 捕获未知错误 try:
阅读全文
posted @ 2019-08-22 23:09
才华配得上梦想
摘要:class MusicPlayer(object): # * 元组 ** 字典 def __new__(cls, *args, **kwargs): # 使用类名创建对象,new方法会被自动调用 print("创建对象,分配空间") # 2 为对象分配空间 instrance = super()._
阅读全文
posted @ 2019-08-22 21:19
才华配得上梦想
摘要:class Game(object): # 定义一个类属性,来记录游戏的历史最高分 top_score = 10 def __init__(self, player_name): self.player_name = player_name @staticmethod def show_help()
阅读全文
posted @ 2019-08-21 22:26
才华配得上梦想
摘要:不同的子类对象调用相同的父类方法,产生不同结果 可以增加代码的灵活度 以继承和重写父类方法为前提 是调用方法的技巧,不会影响到类的内部设计 class Dog(object): def __init__(self, name): self.name = name def game(self): pr
阅读全文
posted @ 2019-08-21 21:00
才华配得上梦想
摘要:单继承 封装根据职责将属性和方法封装到一个抽象的类 继承可以实现代码的重用,相同的代码不需要重复编写 1)语法 class 类名(父类名): pass 子类继承自父类,可以直接使用父类已经封装好的方法 子类应该根据职责,封装子类特有的属性和方法 class Animal: #def __init__
阅读全文
posted @ 2019-08-21 20:59
才华配得上梦想
摘要:01 封装 将属性和方法封装到一个抽象的类中 外界使用类创建对象,然后让对象调用方法 对象方法的细节都被封装在类的内部 02 晓明爱跑步 需求: 1 晓明体重 75.0公斤 2 晓明每次跑步会减肥0.5公斤 3 晓明每次吃东西体重会增加1公斤 name weight __init__(self, n
阅读全文
posted @ 2019-08-20 22:16
才华配得上梦想
摘要:dir 内置函数 变量,数据,函数都是对象 In [9]: def demo(): ...: """这个是测试函数""" ...: print("123") ...: In [10]:dir(demo) #使用内置函数dir传入标志符/数据,可以查看对象内的所有属性和方法 In [10]: demo
阅读全文
posted @ 2019-08-19 22:38
才华配得上梦想
摘要:01 框架搭建 准备文件,确定文件名,保证能够在需要的位置编写代码 编写主运行循环,实现基本的用户输入和判断 1.1 文件准备 1cards_main.py保存主程序功能代码 程序入口 每一次启动名片管理系统都通过main这个文件启动 2新建cards_tools.py保存所有名片功能参数 将对名片
阅读全文
posted @ 2019-08-10 22:32
才华配得上梦想
摘要:程序的三大流程 顺序,分支,循环 循环-- 让特定代码 重复执行 while循环基本使用 1 # 打印5遍hello world 2 #print("hello world " * 5) 3 # 定义一个整数变量,记录循环次数 4 a = 0 5 while a < 5: 6 # 希望在循环内执行的
阅读全文
posted @ 2019-08-08 18:44
才华配得上梦想
摘要:比较 运算符 == != > < >= <= if else格式 if 要判断的条件: #if顶格写然后空一格,加: 条件成立,要做的事情 #缩进四个字节(tab键,建议用空格,不要混用) 1 #定义一个整数变量记录年龄 2 age = 19 3 #判断是否满了18岁 4 if age >= 18:
阅读全文
posted @ 2019-08-08 08:32
才华配得上梦想
摘要:syntax 语法 indentation 缩进 unexpected indent 出乎意料的缩进 declare 公布 interactive 交互式 python shell 交换式 退出解释器 exit() or 快捷键ctrl+d IPython interactive 交互式 自动补全
阅读全文
posted @ 2019-08-06 22:41
才华配得上梦想
摘要:下载并安装 Metricbeat 首次使用 Metricbeat?请参阅入门指南。 复制代码片段 curl -L -O https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-7.2.0-x86_64.rpm sudo r
阅读全文
posted @ 2019-08-05 15:01
才华配得上梦想
摘要:下载并安装 Filebeat 首次使用 Filebeat?请参阅入门指南。 复制代码片段 curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.2.0-x86_64.rpm sudo rpm -vi f
阅读全文
posted @ 2019-08-05 14:49
才华配得上梦想

浙公网安备 33010602011771号