使用 Python 内置的 defaultdict
,我们可以很容易的定义一个树形数据结构:
def tree(): return defaultdict(tree)
就是这样!
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
''' | |
显示树莓派cpu温度、使用率及内存使用率 | |
''' | |
import os | |
def show_temp(): | |
file = open("/sys/class/thermal/thermal_zone0/temp") |
import cv2 | |
import urllib | |
import numpy as np | |
stream=urllib.urlopen('http://192.168.31.249:8080/video') | |
bytes='' | |
while True: | |
bytes+=stream.read(1024) | |
a = bytes.find('\xff\xd8') | |
b = bytes.find('\xff\xd9') |
#!/usr/bin/env python | |
# | |
# Copyright 2001-2002 by Vinay Sajip. All Rights Reserved. | |
# | |
# Permission to use, copy, modify, and distribute this software and its | |
# documentation for any purpose and without fee is hereby granted, | |
# provided that the above copyright notice appear in all copies and that | |
# both that copyright notice and this permission notice appear in | |
# supporting documentation, and that the name of Vinay Sajip | |
# not be used in advertising or publicity pertaining to distribution |
#!/bin/bash | |
# According to: | |
# How To Set Up Python 2.7.6 and 3.3.3 on CentOS 6.4 | |
# https://www.digitalocean.com/community/tutorials/how-to-set-up-python-2-7-6-and-3-3-3-on-centos-6-4 | |
yum -y update | |
yum groupinstall -y 'development tools' | |
yum install -y zlib-dev openssl-devel sqlite-devel bzip2-devel | |
yum install xz-libs | |
wget http://www.python.org/ftp/python/2.7.10/Python-2.7.10.tar.xz |
2017年3月16日 by Ron | |
我是来自AWS 广东社区微信2群的Ron.第一次去参加AWS分享会的时候,第一个上来的就是关于Lambda的.但当时我听完后. | |
觉得这东西耦合度太高,不好.就一直没在去深入了解.那一次技术分享会,还有卓动--张穗文先生分享的Kinesis + RedShift做 | |
用户日志分析,和有米科技的实时日志分析,那个时候真的感叹跟AWS相见恨晚.他们两分享的东西都非常棒,直接驱使我来后自己 | |
去尝试开发Kinesis,SQS等.总体来说,AWS组件很多.但我毕竟刚接触没多久,所以很多AWS的组件和相关概念都还很陌生, | |
或者说根本就不知道是什么东西.以下在阐释的时候,如有偏差或者错误,欢迎拍砖(我Email: [email protected]) | |
在这过去的半年多时间里.所有广州社区的分享会,我都去了.最近一次正好听到胖虎的Lambda的分享会. | |
回来的路上我已经满脑子的开始想我最近的在做的一个东西,是否能用Lambda来实现. |
使用 Python 内置的 defaultdict
,我们可以很容易的定义一个树形数据结构:
def tree(): return defaultdict(tree)
就是这样!
#encoding=utf-8 | |
''' | |
演示如何多进程的使用gevent, | |
1、gevent和multiprocessing组合使用会有很多问题, | |
所以多进程直接用subprocess.Popen,进程间不通过fork共享 | |
任何数据,完全独立运行,并通过socket通信 | |
2、进程间同步不能用multiprocessing.Event, | |
因为wait()的时候会阻塞住线程,其它协程的代码无法执行,也 | |
不能使用gevent.event.Event(),因为它通过multiprocessing.Process | |
共享到子进程后,在父进程set(),子进程wait()是不会收到信号的 |
#coding=utf-8 | |
import time | |
import sched | |
import os | |
import threading | |
""" | |
sched模块,准确的说,它是一个调度(延时处理机制),每次想要定时执行某任务都必须写入一个调度。 | |
使用步骤如下: | |
(1)生成调度器: | |
s = sched.scheduler(time.time,time.sleep) |
from flask import Flask | |
from flask_mail import Mail, Message | |
app = Flask(__name__) | |
app.config.update( | |
#EMAIL SETTINGS | |
MAIL_SERVER='smtp.qq.com', | |
MAIL_PORT=465, | |
MAIL_USE_SSL=True, |
import smtplib | |
from getpass import getpass | |
def prompt(prompt): | |
return input(prompt).strip() | |
fromaddr = prompt("From: ") | |
toaddrs = prompt("To: ").split() | |
subject = prompt("Subject: ") | |
print("Enter message, end with ^D (Unix) or ^Z (Windows):") |