摘要: import socket # 建立socket对象 socket_con = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # 连接指定服务器地址 socket_con.connect(('www.baidu.com', 80)) # 拼接请求报文 # 请求行 request_line = 'GET / HTTP/1.1\r\n' # 请... 阅读全文
posted @ 2018-05-11 23:54 汪凡 阅读(1025) 评论(0) 推荐(0) 编辑
摘要: 1、网络本质 进行资源共享和信息传输。 2、基于网络的应用程序的本质 就是获取数据和传输数据给用户使用。 3、TCP/IP协议栈工作流程 实体层是不属于TCP/IP协议栈的一层。也就是说TCP/IP协议栈共计四层。 首先得接入网络,局域网或者广域网,在计算机接入网络的时候,也就是插入网线的时候本地路 阅读全文
posted @ 2018-05-11 23:51 汪凡 阅读(1020) 评论(0) 推荐(0) 编辑
摘要: def FZZL(): print(" _ooOoo_ ") print(" o8888888o ") print(" 88 . 88 ") print(" ... 阅读全文
posted @ 2018-05-08 17:51 汪凡 阅读(750) 评论(0) 推荐(0) 编辑
摘要: '''import pygame# 初始化pygame库,让计算机硬件准备pygame.init()# 窗口相关操作 # 创建窗口window = pygame.display.set_mode([窗口宽,窗口高])# 设置窗口标题pygame.display.set_caption("窗口标题") 阅读全文
posted @ 2018-05-08 17:48 汪凡 阅读(4325) 评论(0) 推荐(0) 编辑
摘要: rmonth = [0, 31, 29, 31, 30, 31, 30, 31,31, 30, 31, 30, 31] month = [0, 31, 28, 31, 30, 31, 30, 31,31, 30, 31, 30, 31] days = 0 def pd_days(y, m, d): global rmonth, month, days # 判断闰年 if... 阅读全文
posted @ 2018-05-08 17:46 汪凡 阅读(602) 评论(0) 推荐(0) 编辑
摘要: class Animal(object): # 类对象 age = 0 # 公有类属性 __like = None # 私有类属性 def __init__(self): # 魔法方法 self.name = 'haha' # 公有实例属性 self.__sex = 'man' # 私有实例属性 def smile... 阅读全文
posted @ 2018-05-08 17:45 汪凡 阅读(8175) 评论(0) 推荐(0) 编辑
摘要: '''集合的方法 set1.add() set1.update() set1.copy() set1.pop() set1.remove() set1.discard() set1.clear() set1.union() set1.issubset() set1.issuperset... 阅读全文
posted @ 2018-05-08 17:45 汪凡 阅读(252) 评论(0) 推荐(0) 编辑
摘要: # f.write() #字符串写入文件 # # f.writelines #将一串字符串写入文件。 该序列可以是生成字符串的任何可迭代对象,通常是字符串列表 # # f.read([size]) #默认读出文件中所有内容,可以指定size(字节) # # f.readline([size]) #默认每次读取一行,字符串中保留一个尾随的换行字符。 # # f.readl... 阅读全文
posted @ 2018-05-08 17:44 汪凡 阅读(189) 评论(0) 推荐(0) 编辑
摘要: name = 'hello' for x in name: print(x) if x == 'l': break #退出for循环 else: print("==for循环过程中,如果没有break则执行==") name = 'hello' for x in name: print(x) #if x == 'l': ... 阅读全文
posted @ 2018-05-08 17:43 汪凡 阅读(702) 评论(0) 推荐(0) 编辑
摘要: '''字典的方法 d1.get() d1.setdefault() d1.pop() d1.popitem() d1.copy() d1.update() d1.items() d1.keys() d1.values() d1.fromkeys() d1.clear() ''... 阅读全文
posted @ 2018-05-08 17:42 汪凡 阅读(275) 评论(0) 推荐(0) 编辑
摘要: '''字符串的方法 s.index() s.rindex() s.find() s.rfind() s.count() s.replace() s.partition() s.rpartition() s.split() s.rsplit() s.splitlines() s.join() s.strip() s.lstri... 阅读全文
posted @ 2018-05-08 17:42 汪凡 阅读(164) 评论(0) 推荐(0) 编辑
摘要: '''列表的方法 l.index() l.count() l.copy() l.insert() l.append() l.extend() l.pop() l.remove() l.clear() l.sort() l.reverse() ''' l = [... 阅读全文
posted @ 2018-05-08 17:41 汪凡 阅读(193) 评论(0) 推荐(0) 编辑
摘要: '''元组的方法 t.index() t.count() ''' # 元组由于不可更改元组里面的数据(第一层) # 所以元组可操作的方法比较少 t = (1,) # 单个元素,为了区分,加个逗号才叫元组 t1 = (3, 4, 'hello', [2, 3, 'ppp'], 3) print(t1[2]) n1 = t1.count(3) # count(元组里面的元素)同之前的用... 阅读全文
posted @ 2018-05-08 17:40 汪凡 阅读(183) 评论(0) 推荐(0) 编辑
摘要: # 函数的位置参数必须要传实参,可以按位置,也可以按关键字传 # 函数的默认参数可以不传实参,可以按位置,也可以按关键字 # 不定长参数*args只收集位置参数形成元组,不定长参数应放在后面,要不会把实参当做位置参数然后报错 # 用**,只要定义了关键字参数,以后针对这个参数传值就必须是关键字形式传递 # 关键字参数和关键字传值必须放在位置参数(实参)后面 # def add_num(li... 阅读全文
posted @ 2018-05-08 17:40 汪凡 阅读(216) 评论(0) 推荐(0) 编辑
摘要: # 准备空列表 users = [] # 准备当前在线用户 online_user = {} while True: # 打印系统提示 print("欢迎使用 用户注册登录系统V2.0") print("1.登录") print("2.注册") print("3.注销登录") # 获取用户操作 command = input("请输入... 阅读全文
posted @ 2018-05-08 17:37 汪凡 阅读(831) 评论(0) 推荐(0) 编辑
摘要: # 用户输入八位日期 date = input('请输入八位年月日(如20180405):') # 分割年月日 day = int(date[-2:]) month = int(date[4:6]) year = int(date[:4]) print(year, month, day) # 定义闰年开关 if year % 4 == 0 and year % 100 != 100 or yea... 阅读全文
posted @ 2018-05-08 17:36 汪凡 阅读(522) 评论(0) 推荐(0) 编辑
摘要: s = input("请输入一个字符串:") if len(s) > 31: print("您输入的字符串过长,请重新输入:") else: l = len(s) print("字符串的长度:%d" % l) print(s[::-1]) 阅读全文
posted @ 2018-05-08 17:35 汪凡 阅读(277) 评论(0) 推荐(0) 编辑
摘要: name = input('请输入用户名:') password = input('请输入密码:') if 6 <= len(name) <= 20: print('提示:用户名符合命名规则') if password[0].isalpha(): print('提示:密码符合命名规则') else: print('错误:密码命名必须以字母开... 阅读全文
posted @ 2018-05-08 17:34 汪凡 阅读(1144) 评论(0) 推荐(0) 编辑
摘要: a = 'hello world' b = [] for i in a: if '%s:%s' % (i, a.count(i)) not in b: b.append('%s:%s' % (i, a.count(i))) print(b) 阅读全文
posted @ 2018-05-08 17:34 汪凡 阅读(464) 评论(0) 推荐(0) 编辑
摘要: import random office = [[], [], []] teacher = ['t1', 't2', 't3', 't4', 't5', 't6', 't7', 't8'] for t in teacher: of = random.randint(0, 2) office[of].append(t) print(office) i = 0 for x in of... 阅读全文
posted @ 2018-05-08 17:33 汪凡 阅读(1164) 评论(0) 推荐(0) 编辑