
python
adream307
这个作者很懒,什么都没留下…
展开
-
高德地图上那种路况堵得发黑是如何实现的?
原文地址: sh truck bootcamp在前一篇文章中,我们简单的介绍了使用 Arctern分析纽约出租车的的数据。在那个例子中,出租车的数据只有上点和下车点的数据,没有完整的轨迹数据,所以整个分析显得有点意犹未尽。在这篇文章中,我们使用上海市的渣土车数据,该数据包含完整的轨迹数据,所有我们可以实现类似高德地图的功能,分析在特定时间段内那些道路比较拥堵。废话不多说,以下为原文。环境准备安装 Arctern安装 Jupyter在上一步中的 arctern_env 环境中执行以下原创 2020-06-22 10:53:53 · 1868 阅读 · 0 评论 -
高德地图上那种轨迹纠偏是如何实现的
原文地址: nyc taxi bootcamp这里介绍一个好玩的开源项目Arctern。这个项目好玩在哪里呢,下图是纽约出租车上车点的原始数据我们可以看到原创 2020-06-16 16:45:35 · 3512 阅读 · 0 评论 -
plotly绘制轮廓图
参考代码: plotlyimport plotly.express as pxg0={'type': 'Polygon', 'coordinates': [[[-86.496774, 32.344437], [-86.717897, 32.402814], [-86.814912, 32.340803], [-86.890581, 32.502974], [-86.917595, 32.664169], [-86.71339, 32.661732], [-86.714219, 32.705694],原创 2020-06-08 19:34:39 · 839 阅读 · 0 评论 -
[python]yield测试
python函数运行到yield的地方暂停,并返回。调用next后冲上次yield结束的位置重新运行测试程序如下:def yield_test(): print("first") yield 1 print("second") yield 2for x in yield_test(): print("=======") print(x) ...原创 2020-04-21 20:51:49 · 262 阅读 · 0 评论 -
[转载]海量向量搜索引擎 Milvus 开源啦
来源:https://zilliz.blog.youkuaiyun.com/article/details/102574264一个非常好玩的向量检索引擎,可以在单机实现十亿向量的高性能检索新手教程:如何玩转十亿向量检索github地址: milvus...转载 2019-10-25 13:27:08 · 996 阅读 · 0 评论 -
[python]抓取股票交易记录
#!/usr/bin/python#DownByDate.py sh600115 2014-12-29 2015-3-15#DownByDate.py stock_num start_date end_date#http://stock.gtimg.cn/data/index.php?appn=detail&action=download&c=sh600115&d=20141229#sh原创 2015-01-06 22:52:05 · 8223 阅读 · 0 评论 -
[Python]操作Mysql数据库
#!/usr/bin/python#InsertData file1 file2#file_name like sh600115_2014-12-29.txtimport sysimport MySQLdbimport csvimport datetimemysql_host='localhost'mysql_user='stock'mysql_passwd='stock'm原创 2015-01-06 22:50:05 · 691 阅读 · 0 评论 -
Ubuntu-Python2.7安装 scipy,numpy,matplotlib
sudo apt-get install python-scipysudo apt-get install python-numpysudo apt-get install python-matplotlibpythonimport scipyimport numpyimport pylabscipy.test()numpy.test()pylab.test()原创 2013-02-01 23:26:04 · 56770 阅读 · 4 评论 -
生产tornado所需的cookie_secret的方法
原地址:http://www.v2ex.com/t/12646import base64import uuidbase64.b64encode(uuid.uuid4().bytes + uuid.uuid4().bytes)转载 2012-05-26 10:25:50 · 5653 阅读 · 0 评论 -
python--单元测试--unittest
#widget.py # -*- coding: utf-8 -*- class Widget: def __init__(self,size=(40,40)): self._size = size def getSize(self): return self._size def reSize(self,width,height): if width原创 2011-05-05 16:48:00 · 944 阅读 · 0 评论 -
vim常用设置
查找 /string 向前搜索指定字符串 ?string 向后搜索指定字符串 n 搜索指定字符串的下一个出现位置 N 搜索指定字符串的上一个出现位置 :%s/old/new/g 全文替换指定字符串 去掉查找高亮 方法一::nohlsearch 方法二:/awertgvcxz (查找一个肯定不存在的字符串) 设置了高亮搜索(:set hlsearch)以后,可以通过 :set nohlsearch原创 2011-04-30 19:55:00 · 840 阅读 · 0 评论 -
[python]模拟浏览器下载网页
#!/usr/bin/python#DownLoad.py source_url dest_fileimport sysimport urllibsrc_url=sys.argv[1];dest_file=sys.argv[2];download=urllib.FancyURLopener();download_page=download.open(src_url);savef原创 2015-01-06 22:47:46 · 1701 阅读 · 0 评论 -
pyton直接发送底层TCP数据包
#!/usr/bin/env python#send_package_on_wire.pyfrom scapy.all import IP,TCP,UDP,conf,sendprotocol='tcp'src_ip='192.168.1.108'dst_ip='192.168.1.100'src_port = 12345dst_port = 12345iface='wlan0'原创 2015-08-02 12:42:11 · 1070 阅读 · 0 评论 -
[python]http_server
#!/usr/bin/env python'''http_server.pyprint the input arguments and set cookies'''from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServerfrom urlparse import urlparse, parse_qsimport rand原创 2015-09-04 09:59:41 · 688 阅读 · 0 评论 -
[pyqt]文本框自动补全
from PyQt4.QtCore import *from PyQt4.QtGui import *import sys class TextEdit(QTextEdit): def __init__(self,parent=None): super(TextEdit,self).__init__(parent) self.cmp=None转载 2015-10-22 22:22:29 · 2864 阅读 · 0 评论 -
[python] yield example
yield example in python原创 2016-04-14 22:00:20 · 644 阅读 · 0 评论 -
一步一步编写12306抢票软件
本文在Linux平台上,以Python为开发工具,介绍12306抢票软件的基本原理,并引入示例,讲解如何自己编写一个12306抢票软件。对于Windows平台的读者,可以安装Crywin软件模拟UNIX的命令行界面。图形界面采用Python封装的Qt图形库。在第一章中,我们举了个例子,讲如如何利用Linux系统中现存的curl、grep和sed抓取制定日期,指定车次的剩余票数。在第二章中,我们...原创 2016-12-23 20:41:15 · 56220 阅读 · 80 评论 -
[cuda]使用shuffle实现的reduce操作
#include<stdio.h>#include"UnifiedMemory.h"__global__ void sum_test(int *src, int *dst, int num){ int pos_start = blockIdx.x * blockDim.x + threadIdx.x; int pos_step = blockDim.x * gri...原创 2018-11-07 11:36:35 · 1225 阅读 · 0 评论 -
[c++]获得this指针的shared_ptr
//shared_from_this.cpp#include <memory>#include <iostream>class TT:public std::enable_shared_from_this<TT>{public: TT(int v):v_(v){} std::shared_ptr<TT> GetSharedPtr(){...原创 2019-01-26 15:39:26 · 1996 阅读 · 0 评论 -
python—sleep
import time time.sleep(1) time.sleep(0.01) time.sleep.__doc__ print(time.ctime()) sleep(10) print(time.ctime()) t1=time.time() sleep(10) t2=time.time() print(t2-t1) print(time.__原创 2011-03-07 10:36:00 · 840 阅读 · 0 评论 -
开10个子进程,等子进程结束再执行主程序
import subprocess processes = [subprocess.Popen("ping 192.168.0.200 -n 1 -w 5000") for i in range(10)] [p.wait() for p in processes] print('Hello world'); #在 window 下 ping 192.168.0.200 -n 1 -w 5000 当ping一个不存在的地址时,上述命令相当于延迟 5s原创 2011-04-29 22:06:00 · 1074 阅读 · 0 评论 -
__init__.py
在目录内增加一个 __init__.py使得该目录可以被当作模块导入 init_test/ |___ test/ | |__ __init__.py | |__ test.py |___ test.py #init_test/test/__init__.py原创 2011-06-21 09:18:00 · 1182 阅读 · 0 评论 -
{PyQT4}集中处理无handle的Exception—sys.excepthook
http://stackoverflow.com/questions/1261668/cannot-override-sys-excepthook # -*- coding: utf-8 -*- from PyQt4.QtCore import * from PyQt4.QtGui import * import sys class Test(QDialog): def __init__(self,parent=None): super(Tes原创 2011-04-24 18:08:00 · 1515 阅读 · 0 评论 -
PyQt4-Widget
# -*- coding: UTF-8 -*- from PyQt4.QtGui import * from PyQt4.QtCore import * import sys app = QApplication(sys.argv) window = QWidget() window.setWindowTitle('Enter Your Age') spinBox = QSpinBox() slider = QSlider(Qt.Horizontal) spinB原创 2011-03-12 17:02:00 · 909 阅读 · 0 评论 -
Qt Designer
如图所示,控件的位置只需大概对齐即可 选择Label 与 lineEdit这这个控件,点击右键,选择“布局”,再选择“水平布局”;对剩下的三个控件采用同样的操作,结果如下图所示: 点击窗体的空白处,不选择任何控件,点击右键,选择“布局”,再选择“垂直布局” 结果如下图所示: 选择菜单栏内的“窗体”,选择“调整大小” 结果如下图所示: 将文件另存为 9.ui,在cmd中进入9.ui所在的目录,输入: pyu原创 2011-03-13 20:15:00 · 793 阅读 · 0 评论 -
python31格式化字符串
http://www.pythonclub.org/python-basic/print nHex=0x20 nstr=’nHex=%x,nDec=%d,nOct=%o’%(nHex,nHex,nHex) print(nstr) import math #default print( "PI = %f"%(math.pi)) #width = 10,precise = 3,align = left print("PI = %10.3f"%(math.pi))原创 2011-03-11 13:41:00 · 623 阅读 · 0 评论 -
以16进制打印byte
import struct x=b’/x58’ x=x+b’/x00/x00/x00’ x=struct.unpack(‘i’,x) print(hex(x[0]))原创 2011-03-11 10:22:00 · 1066 阅读 · 0 评论 -
for循环求最大值与最小值
import math begins=4 dsg = 3.1, 31, 45, 1031 cuts=[math.fabs(cs-begins) for cs in dsg] min(cuts) max(cuts)原创 2011-02-17 13:08:00 · 9000 阅读 · 0 评论 -
list排序
运行环境 python 3.1 已知一列表x如下: x=list() x.append(dict(sum=5,x=1)) x.append(dict(sum=4,x=2)) x.append(dict(sum=3,x=3)) x.append(dict(sum=2,x=4)) x.append(dict(sum=1,x=5)) x.sort(key=lambda i : i[‘sum’]) 排序之后,x如下: [{‘x’: 5, ‘s原创 2011-03-05 16:51:00 · 626 阅读 · 0 评论 -
把N表示成M个数相加之和
import copy M=4; N=9; p=list(); pm=list(range(M)); def partition(index): global p,pm if index==M: if sum(pm)==N: pmp=copy.deepcopy(pm) pmp.sort() if not pmp in p:原创 2011-02-19 13:36:00 · 1551 阅读 · 0 评论 -
将字符3转换成数字3,再存入Bytes内,最后通过串口发送出去
从文件内读取数据,通过串口发送数据,然后接收响应 文件数据格式:01 00 00 01 03 02 01 03 03 03 00 03 03 00 01 03 01 03 01 03 01 00 00 01 02 01 00 01 02 00 01 01 01 01 00 01 01 03 00 01 03 01 00 03 03 02 00 01 00 01 01 01 00 01 00 03 03 03 01 01 01 00 ff. 这是用字符形式表示的16机制数据 首先通过Read原创 2010-12-17 17:56:00 · 1098 阅读 · 0 评论 -
用QtDesigner设计界面
代码格式-1 # -*- coding: utf-8 -*- from PyQt4.QtCore import * from PyQt4.QtGui import * import sys import ui_10_1,ui_10_2,ui_10_3 class TestDialog(QDialog): def __init__(self,parent=None): super(TestDialog,self).__init__(parent原创 2011-03-14 22:36:00 · 1595 阅读 · 0 评论 -
PyQt4--QLineEdit内引入正则表达式
from PyQt4.QtCore import * from PyQt4.QtGui import * import sys QTextCodec.setCodecForTr(QTextCodec.codecForName("utf8")) class FindCell(QDialog): def __init__(self,parent=None): super(FindCell,self).__init__(parent) se原创 2011-03-15 10:38:00 · 2118 阅读 · 0 评论 -
PyQt4—QtDesigner--QGridLayout跨行
如上图所示,选中一个控件的边缘,向右边拖动,结果如下图所示:原创 2011-03-14 15:18:00 · 3209 阅读 · 0 评论 -
PyQt4--发送带参数的自定义信号
http://www.saltycrane.com/blog/2008/01/pyqt-how-to-pass-arguments-while/ import sys import time from PyQt4.QtCore import * from PyQt4.QtGui import * #################################################################### class MyWindow(QWid原创 2011-04-09 16:53:00 · 6221 阅读 · 2 评论 -
PyQt4--QPushButton阵列
http://stackoverflow.com/questions/5364291/how-to-pass-arguments-to-a-function-using-a-predefined-signal-in-pyqt # -*- coding: utf-8 -*- from PyQt4.QtCore import * from PyQt4.QtGui import * import sys import functools class Dialog(QDialog):原创 2011-04-09 16:41:00 · 3409 阅读 · 0 评论 -
PyQt4--QThread实现界面与算法的分离--2
PyQt4实时显示的另一种实现方式 # -*- coding: utf-8 -*- from PyQt4.QtCore import * from PyQt4.QtGui import * import sys import os import time class Test(QDialog): def __init__(self,parent=None): super(Test,self).__init__(parent)原创 2011-04-08 13:40:00 · 6806 阅读 · 0 评论 -
pyQt4实时显示--QApplication.processEvents
# -*- coding: utf-8 -*- from PyQt4.QtCore import * from PyQt4.QtGui import * import sys import os import time class Test(QDialog): def __init__(self,parent=None): super(Test,self).__init__(parent) self.li原创 2011-04-08 11:14:00 · 5840 阅读 · 0 评论 -
PyQt4--QThread实现界面与算法分离
http://www.diotavelli.net/PyQtWiki/Threading%2C_Signals_and_Slots import math, random, sys from PyQt4.QtCore import * from PyQt4.QtGui import * class Window(QWidget): def __init__(self, parent = None): QWidget.__init__(self, p原创 2011-04-08 13:37:00 · 5865 阅读 · 0 评论 -
QMessageBox.about -- 超连接
# -*- coding: utf-8 -*- from PyQt4.QtCore import * from PyQt4.QtGui import * import sys QTextCodec.setCodecForTr(QTextCodec.codecForName("utf8")) app = QApplication(sys.argv) dlg = QMessageBox.about(None,"hello","哈尔滨工业大学"); sys.exit(0)原创 2011-05-17 19:04:00 · 1822 阅读 · 0 评论