摘要:
dic_1 = {'a':111,'b':222} dic_2 = {'c':333,'d':444} dic = {**dic_1,**dic_2} print(dic) # {'a': 111, 'b': 222, 'c': 333, 'd': 444} {**字典名,**字典名2} 进行合并字 阅读全文
posted @ 2020-05-07 19:43
Hany47315
阅读(227)
评论(0)
推荐(0)
摘要:
''' abs函数:如果参数为实数,则返回绝对值 如果参数为复数,则返回复数的模 ''' a = 6 b = -6 c = 0 # print("a = {0} , b = {1} , c = {2}".format(abs(a),abs(b),abs(c))) # a = 6 , b = 6 , 阅读全文
posted @ 2020-05-07 19:41
Hany47315
阅读(218)
评论(0)
推荐(0)
摘要:
txt = '我是字符串' txt_encode = txt.encode() print(txt) # 我是字符串 print(txt_encode) # b'\xe6\x88\x91\xe6\x98\xaf\xe5\xad\x97\xe7\xac\xa6\xe4\xb8\xb2' print(t 阅读全文
posted @ 2020-05-07 19:37
Hany47315
阅读(958)
评论(0)
推荐(0)
摘要:
# WSGI服务器调用 def application(environ,start_response): start_response('200 OK',[('Content-Type','text/html')]) return 'Hello World' ''' environ: 包含HTTP请 阅读全文
posted @ 2020-05-07 19:35
Hany47315
阅读(132)
评论(0)
推荐(0)
摘要:
import time # WSGI允许开发者自由搭配web框架和web服务器 def app(environ,start_response): status = '200 OK' response_headers = [('Content-Type','text/html')] start_res 阅读全文
posted @ 2020-05-07 19:34
Hany47315
阅读(280)
评论(0)
推荐(0)
摘要:
""" 创建udp连接 发送数据给 """ from socket import * # 创建udp套接字,使用SOCK_DGRAM udp_socket = socket(AF_INET,SOCK_DGRAM) # 准备接收方的地址 dest_addr = ('',8080)#主机号,固定端口号 阅读全文
posted @ 2020-05-07 19:32
Hany47315
阅读(241)
评论(0)
推荐(0)
摘要:
""" 建立->绑定本地ip地址和端口号->接收数据->转码输出->关闭客户端 """ from socket import * udp_socket = socket(AF_INET,SOCK_DGRAM) # 绑定本地的相关信息,如果网络程序不绑定,则系统会随机分配 # UDP使用SOCK_DG 阅读全文
posted @ 2020-05-07 19:31
Hany47315
阅读(330)
评论(0)
推荐(0)
摘要:
""" 建立tcp服务器 绑定本地服务器信息(ip地址,端口号) 进行监听 获取监听数据(监听到的客户端和地址) 使用监听到的客户端client_socket获取数据 输出获取到的数据 并返回给客户端一个数据 关闭服务器端 """ from socket import * # 创建tcp socke 阅读全文
posted @ 2020-05-07 19:30
Hany47315
阅读(314)
评论(0)
推荐(0)
摘要:
""" 创建客户端 绑定服务器ip地址和端口号(端口号是整型) 与服务器建立连接 发送给服务器要发送的数据(转码) 接收服务器返回的数据 关闭客户端 """ from socket import * # 创建tcp socket tcp_client_socket = socket(AF_INET, 阅读全文
posted @ 2020-05-07 19:28
Hany47315
阅读(298)
评论(0)
推荐(0)
摘要:
我会尽快将以前打过的代码都发布出来,然后 抓紧学习 Django ~ 😂随时复习,电脑复习有点不方便了 2020-05-07 阅读全文
posted @ 2020-05-07 19:27
Hany47315
阅读(88)
评论(0)
推荐(0)
摘要:
import numpy as np n = np.array(([1,2,3],[4,5,6],[7,8,9])) ''' array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) ''' # 第一行元素 n[0] # array([1, 2, 3]) # 第一行第三列元素 阅读全文
posted @ 2020-05-07 19:18
Hany47315
阅读(2257)
评论(0)
推荐(0)
摘要:
import numpy as np x = np.array((1,2,3,4,5)) # 使用 * 进行相乘 x*2 # array([ 2, 4, 6, 8, 10]) # 使用 / 进行相除 x / 2 # array([0.5, 1. , 1.5, 2. , 2.5]) 2 / x # a 阅读全文
posted @ 2020-05-07 19:10
Hany47315
阅读(458)
评论(0)
推荐(0)
摘要:
import numpy as np # 将 0~100 10等分 x = np.arange(0,100,10) # array([ 0, 10, 20, 30, 40, 50, 60, 70, 80, 90]) # 每个数组元素对应的正弦值 np.sin(x) ''' array([ 0. , 阅读全文
posted @ 2020-05-07 19:07
Hany47315
阅读(369)
评论(0)
推荐(0)
摘要:
import numpy as np x = np.array([1,4,5,2]) # array([1, 4, 5, 2]) # 返回排序后元素的原下标 np.argsort(x) # array([0, 3, 1, 2], dtype=int64) # 输出最大值的下标 x.argmax( ) 阅读全文
posted @ 2020-05-07 19:06
Hany47315
阅读(361)
评论(0)
推荐(0)
摘要:
import numpy as np n = np.arange(10) # array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) # 查看数组的大小 n.size # 10 # 将数组分为两行五列 n.shape = 2,5 ''' array([[0, 1, 2, 3, 4 阅读全文
posted @ 2020-05-07 19:04
Hany47315
阅读(1042)
评论(0)
推荐(0)
摘要:
# 导入numpy 并赋予别名 np import numpy as np # 创建数组的常用的几种方式(列表,元组,range,arange,linspace(创建的是等差数组),zeros(全为 0 的数组),ones(全为 1 的数组),logspace(创建的是对数数组)) # 列表方式 n 阅读全文
posted @ 2020-05-07 19:02
Hany47315
阅读(328)
评论(0)
推荐(0)
摘要:
import numpy as np x = np.arange(8) # [0 1 2 3 4 5 6 7] # 在数组尾部追加一个元素 np.append(x,10) # array([ 0, 1, 2, 3, 4, 5, 6, 7, 10]) # 在数组尾部追加多个元素 np.append(x 阅读全文
posted @ 2020-05-07 19:00
Hany47315
阅读(18152)
评论(0)
推荐(0)
摘要:
import numpy as np # 生成一个随机数组 np.random.randint(0,6,3) # array([1, 1, 3]) # 生成一个随机数组(二维数组) np.random.randint(0,6,(3,3)) ''' array([[4, 4, 1], [2, 1, 0 阅读全文
posted @ 2020-05-07 18:59
Hany47315
阅读(493)
评论(0)
推荐(0)
摘要:
# 重采样 多索引 标准差 协方差 import pandas as pd import numpy as np import copy # 设置列对齐 pd.set_option("display.unicode.ambiguous_as_wide",True) pd.set_option("di 阅读全文
posted @ 2020-05-07 18:58
Hany47315
阅读(464)
评论(0)
推荐(0)
摘要:
# C:\Users\lenovo\Desktop\总结\Python # 读取 Excel 文件并进行筛选 import pandas as pd # 设置列对齐 pd.set_option("display.unicode.ambiguous_as_wide",True) pd.set_opti 阅读全文
posted @ 2020-05-07 18:55
Hany47315
阅读(13733)
评论(0)
推荐(1)
摘要:
# 查看数据特征和统计信息 import pandas as pd # 读取文件 dataframe = pd.read_excel(r'C:\Users\lenovo\Desktop\总结\Python\超市营业额.xlsx') # 查看所有的交易额信息 dataframe['交易额'].desc 阅读全文
posted @ 2020-05-07 18:54
Hany47315
阅读(4536)
评论(0)
推荐(0)
摘要:
对Series 对象使用匿名函数 使用 pipe 函数对 Series 对象使用 匿名函数 pd.Series(range(5)).pipe(lambda x,y,z :(x**y)%z,2,5) pd.Series(range(5)).pipe(lambda x:x+3).pipe(lambda 阅读全文
posted @ 2020-05-07 18:52
Hany47315
阅读(302)
评论(0)
推荐(0)
摘要:
# 时间序列和常用操作 import pandas as pd # 每隔五天--5D pd.date_range(start = '20200101',end = '20200131',freq = '5D') ''' DatetimeIndex(['2020-01-01', '2020-01-06 阅读全文
posted @ 2020-05-07 18:49
Hany47315
阅读(528)
评论(0)
推荐(0)
摘要:
import pandas as pd # 设置列对齐 pd.set_option("display.unicode.ambiguous_as_wide",True) pd.set_option("display.unicode.east_asian_width",True) # 读取工号姓名时段交 阅读全文
posted @ 2020-05-07 18:48
Hany47315
阅读(472)
评论(0)
推荐(1)
摘要:
import pandas as pd import numpy as np # 读取全部数据,使用默认索引 data = pd.read_excel(r'C:\Users\lenovo\Desktop\总结\Python\超市营业额.xlsx') # 修改异常值 data.loc[data.交易额 阅读全文
posted @ 2020-05-07 18:46
Hany47315
阅读(2879)
评论(0)
推荐(0)
摘要:
# 处理异常值缺失值重复值数据差分 import pandas as pd import numpy as np import copy # 设置列对齐 pd.set_option("display.unicode.ambiguous_as_wide",True) pd.set_option("di 阅读全文
posted @ 2020-05-07 18:44
Hany47315
阅读(752)
评论(0)
推荐(0)
摘要:
# 分组与聚合 import pandas as pd import numpy as np # 设置列对齐 pd.set_option("display.unicode.ambiguous_as_wide",True) pd.set_option("display.unicode.east_asi 阅读全文
posted @ 2020-05-07 18:41
Hany47315
阅读(413)
评论(0)
推荐(0)
摘要:
# 使用透视表与交叉表查看业绩汇总数据 import pandas as pd import numpy as np import copy # 设置列对齐 pd.set_option("display.unicode.ambiguous_as_wide",True) pd.set_option(" 阅读全文
posted @ 2020-05-07 18:36
Hany47315
阅读(740)
评论(0)
推荐(0)
摘要:
C:\Users\lenovo\Desktop\总结\Python\超市营业额.xlsx 这个文档自己创建就可以,以下几篇文章仅作为参考 import pandas as pd import copy # 设置列对齐 pd.set_option("display.unicode.ambiguous_ 阅读全文
posted @ 2020-05-07 18:33
Hany47315
阅读(265)
评论(0)
推荐(0)
摘要:
# 一维数组与常用操作 import pandas as pd # 设置输出结果列对齐 pd.set_option('display.unicode.ambiguous_as_wide',True) pd.set_option('display.unicode.east_asian_width',T 阅读全文
posted @ 2020-05-07 18:31
Hany47315
阅读(826)
评论(0)
推荐(0)
摘要:
# DateFrame 的创建,包含部分:index , column , values import numpy as np import pandas as pd # 创建一个 DataFrame 对象 dataframe = pd.DataFrame(np.random.randint(1,2 阅读全文
posted @ 2020-05-07 18:29
Hany47315
阅读(185)
评论(0)
推荐(0)
摘要:
连接 mysql 驱动 mysq1-client python2,3都能直接使用 对myaq1安装有要求,必须指定位置存在 配置文件 python-mysql python3 不支持 pymysql python2, python3都支持 还可以伪装成前面的库 2020-05-07 阅读全文
posted @ 2020-05-07 18:07
Hany47315
阅读(1153)
评论(0)
推荐(0)
摘要:
在项目的 settings 中修改 DATABASES = { 'default': { # 'ENGINE': 'django.db.backends.sqlite3', # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 'ENGINE':'djang 阅读全文
posted @ 2020-05-07 18:05
Hany47315
阅读(170)
评论(0)
推荐(0)
摘要:
查找所有的元素 Student.objects.all() 查找单个元素 Student.objects.get(主键=值) 主键 pk = xxx 更新数据库数据后进行保存 stu.save() 删除数据库表中的行 stu.delete() 需要注意的点: update_student 函数和 d 阅读全文
posted @ 2020-05-07 17:42
Hany47315
阅读(369)
评论(0)
推荐(0)
摘要:
安装 you-get 和 ffmpeg ffmpeg 主要是下载之后,合并音频和视频 pip install you-get -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com pip install ffmpeg -i 阅读全文
posted @ 2020-05-07 16:29
Hany47315
阅读(765)
评论(0)
推荐(0)
摘要:
[] 和 () 创建的列表推导式不同 lst = [i for i in range(4)] print(lst) print(type(lst)) gen = (i for i in range(4)) print(gen) print(type(gen)) 对 () 创建的对象进行遍历 gen 阅读全文
posted @ 2020-05-07 13:02
Hany47315
阅读(952)
评论(0)
推荐(0)
摘要:
在 views 中实现对数据库的添加和读取数据库 添加数据 对象 = models 中创建的类名() 对象.列名 = '字段值' 对象.save() 进行保存 return HttpResponse('提示信息') def add_student(request): stu = Student() 阅读全文
posted @ 2020-05-07 11:40
Hany47315
阅读(717)
评论(0)
推荐(0)
摘要:
流程:1.用户需求分析 2.概念结构设计 3.逻辑结构设计(规范化) 4.数据库的物理结构设计 E-R 模型 -> 关系数据模型步骤①为每个实体建立-张表 ②为每个表选择一一个主键(建议添加一-个没有实际意义的字段作为主键) ③使用外键表示实体间关系 ④定义约束条件 ⑤评价关系的质量,并进行必要的改 阅读全文
posted @ 2020-05-07 10:46
Hany47315
阅读(849)
评论(0)
推荐(0)
摘要:
在 创建好的 app 目录下的 models.py 中,编写创建 数据库表的限制条件 class Student(models.Model): s_name = models.CharField(max_length=16) s_age = models.IntegerField(default=1 阅读全文
posted @ 2020-05-07 09:40
Hany47315
阅读(196)
评论(0)
推荐(0)

浙公网安备 33010602011771号