python
ailinyingai
DevOps 搬砖人 干饭人
展开
-
sqlite-python3
import sqlite3 import sysimport osdropbox = os.getenv("dropbox")config = os.getenv("my_config")dbfile = ("Databases\jarvis.db")listfile = ("sqlite_master_table.lst")master_db = os.path.join(dropbox, dbfile)config_file = os.path.原创 2021-12-01 20:59:57 · 1067 阅读 · 0 评论 -
salt 问题
对salt-api进行了二次开发,通过api控制minion,可能会遇到发送命令线程就进入了等待,然后就是超时。解决方法:salt.netapi.rest_cherrypy包里面有一个app.py方法,修改’server.thread_pool’: self.apiopts.get(‘thread_pool’, 100)为200,修改’server.socket_queue_size’: sel...原创 2019-08-29 17:18:26 · 302 阅读 · 0 评论 -
py25
1.到底什么是Python?你可以在回答中与其他技术进行对比下面是一些关键点:Python是一种解释型语言。这就是说,与C语言和C的衍生语言不同,Python代码在运行之前不需要编译。其他解释型语言还包括PHP和Ruby。Python是动态类型语言,指的是你在声明变量时,不需要说明变量的类型。你可以直接编写类似x=111和x="I’m a string"这样的代码,程序不会报错。成长离不开...翻译 2019-08-14 17:07:13 · 170 阅读 · 0 评论 -
cloudify的基础总结
一个与Paas相关的开源平台 cloudify cloudify是一个开源的云应用编排系统,可以让你的应用自动化在各种不同的云上方便地部署。从3.0开始,整个技术栈几乎完全转移到了python上面(除了保留一个java开发的组件外)。 cloudify是干什么的呢?从蓝图到生产环境,简单来说,就是允许运维和开发人员使用一种语言描述IT拓扑架构,并且部署到任意环境中,确保环境之间的无差异。 c原创 2017-06-06 22:09:49 · 1813 阅读 · 0 评论 -
python_manual
python实例手册“`pythonencoding:utf8设定编码-支持中文查看帮助 import os for i in dir(os): print i # 模块的方法 help(os.path) # 方法的帮助变量r=r'\n' # 输出时原型打印u=u'中文' # 定义为unic转载 2017-05-11 21:21:21 · 2217 阅读 · 0 评论 -
python-web开发1
python web开发1mvc模型 是在软件工程当中广泛使用的设计模式,分为三个层次:模型 视图 控制。之前接触的ruby rails开发也是mvc模型。 1.django框架初识 如何安装就不介绍了。 环境是python3,采用pip安装的话,django的版本会比较高。建议正式开发还是使用低版本,资料可能会多些,国内普遍采用的版本也该较低。 使用命令直接利用框架生成文件架构原创 2017-03-19 21:02:17 · 244 阅读 · 0 评论 -
git push 避免重复输入用户名和密码
touch .git-credentials vim .git-credentials https://{username}:{password}@github.com 添加Git Config 内容 进入git bash终端, 输入如下命令: git config --global credential.helper store 执行完转载 2016-07-18 22:21:21 · 613 阅读 · 0 评论 -
five tips for good git commit
git转载 2016-07-17 22:35:24 · 375 阅读 · 0 评论 -
爬虫小实验
import requests, json, time, pymongo, randomfrom bs4 import BeautifulSoup# client = pymongo.MongoClient()# ganji = client['ganji']# url_list = ganji['url_list']# item_info = ganji['item_info']head原创 2016-04-29 23:30:45 · 5607 阅读 · 0 评论 -
集体智慧编程——提供推荐
我们在网站上需要做的第一件事情是提供推荐:critics={'Lisa Rose': {'Lady in the Water': 2.5, 'Snakes on a Plane': 3.5, 'Just My Luck': 3.0, 'Superman Returns': 3.5, 'You, Me and Dupree': 2.5, 'The Night Listener': 3.0},'翻译 2016-03-14 09:40:40 · 408 阅读 · 0 评论 -
python小项目1
做为 Apple Store App 独立开发者,你要搞限时促销,为你的应用生成激活码(或者优惠券),使用 Python 如何生成 200 个激活码(或者优惠券)?#!/usr/bin/env python# -*- coding: utf-8 -*-from random import Randomdef cod原创 2016-04-05 13:23:15 · 477 阅读 · 0 评论 -
mac 安装pygame
1) Install XCode and command line tools2) Install Homebrew (ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)")3) brew install Python34) brew install git5) brew install sd原创 2016-04-05 10:04:44 · 894 阅读 · 0 评论 -
发送邮件
#!/usr/bin/python#-*- coding: utf-8 -*-import smtplibfrom email.mime.text import MIMETextfrom email.mime.multipart import MIMEMultipartfrom email.header import Headersender = 'x@163.com'to = ["y原创 2016-01-15 11:39:19 · 448 阅读 · 0 评论 -
从百度贴吧抓取楼主的发帖
# -*- coding: utf-8 -*-import stringimport urllib2import re#----------- 处理页面上的各种标签 -----------class HTML_Tool: # 用非 贪婪模式 匹配 \t 或者 \n 或者 空格 或者 超链接 或者 图片 BgnCharToNoneRex = re.compile("(\t|\n原创 2016-01-12 21:00:59 · 1111 阅读 · 0 评论 -
tushare作图
如何从tushare读取平安银行股价,并作图#!/usr/bin/python2.7import matplotlibimport tushare as tsimport pandas as pdimport matplotlib.pyplot as pltfig = plt.gcf()df=ts.get_hist_data('000001',start='2015-11-01',end=原创 2016-01-12 20:11:18 · 4007 阅读 · 0 评论 -
使用python的pillow
使用python的pillowimport PIlfrom PIL import Imageim1=Image.open("lily.jpg")im2=Image.Image()im1,im2im1.show()im5=im1.convert("L")im6=im1.rotate(-45)convert是转换颜色模式rotate则是旋转 顺时针旋转45度原创 2015-12-07 17:44:25 · 356 阅读 · 0 评论 -
通过百度api得到ip信息
# -*- coding: utf-8 -*-import urllib,urllib2,jsonip=raw_input("输入查询的ip地址:")url ='http://apis.baidu.com/apistore/iplookupservice/iplookup?ip='+ipreq=urllib2.Request(url)req.add_header("apikey","a转载 2015-12-28 12:13:45 · 1246 阅读 · 0 评论