![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
ruofeng133
技术美术
展开
-
python拖拽显示直方图
https://blog.csdn.net/lanlanmingyue/article/details/102745376安装依赖pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pillowpip install -i https://pypi.tuna.tsinghua.edu.cn/simple matplotlibzft.py# -*- coding: utf-8 -*-import sysfrom PIL imp.原创 2021-12-11 12:53:38 · 2423 阅读 · 0 评论 -
Mumu模拟器连接脚本
https://www.cnblogs.com/lancidie/p/9619372.html#!/usr/bin/env pythonimport osimport sysCmd_kill = "adb kill-server"Cmd_start = "adb start-server"Cmd_connect = "adb connect 127.0.0.1:7555"Cmd_devices = "adb devices"Cmd_profiler = "adb forward t.原创 2021-10-30 21:18:11 · 4898 阅读 · 0 评论 -
fbx sdk python by pycharm
老是报错误提示,终于解决了直接下载python3.3的版本复制这里的文件到注意,一定要新建一个空的文件夹新建一个空的文件夹新建一个空的文件夹不然pycharm不会识别fbx这个手动添加的包然后就可以尽情的玩耍啦自动完成就是666...原创 2021-07-18 00:43:18 · 1444 阅读 · 3 评论 -
Python拼接图像 Pillow
拼接指定的图像from PIL import Imageimport osdef GetFileFromThisRootDir(dir, ext=None): allfiles = [] needExtFilter = (ext != None) for root, dirs, files in os.walk(dir): for filespath in files: filepath = os.path.join(root,.原创 2021-05-20 20:04:41 · 621 阅读 · 0 评论 -
Blender 导入csv文件from renderdoc
https://github.com/sbobovyc/GameTools/blob/master/Blender/import_pix.py这个脚本目前使用是直接在blender里运行脚本 然后导入 试试呗原创 2020-11-29 13:47:22 · 1801 阅读 · 0 评论 -
python 读写并裁剪文件
比如把文件内容xx123 变成 123https://blog.csdn.net/yang520java/article/details/82660786with open("111.txt", 'rb+') as f: s = f.read()r s = s[2:] with open("222.txt", 'wb+') as f2: f2.write(s)原创 2020-11-18 13:28:15 · 314 阅读 · 0 评论 -
python 限制递归次数
好长时间没写过递归了。来一个python实现一下 ????def ss(n): if n < 0: return print("ss" + str(n)) ss(n-1)ss(6)输出======ss6ss5ss4ss3ss2ss1ss0>>> ...原创 2020-04-01 21:59:52 · 722 阅读 · 0 评论 -
二维码生成
import qrcodeencodeUrl = input("input url: ")qr = qrcode.QRCode( version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=10, border=4,)qr.add_data(encodeUr...原创 2019-03-24 09:56:19 · 242 阅读 · 0 评论 -
python 全排列
python 全排列题目现在有 5 张扑克牌,其中 2 张是王牌(大小王),J、Q、K 各一张。将这 5 张牌排成一排,左端或者右端至少有一端王牌的排法有多少种?请说明计算方法# coding:utf-8C = ['大王','小王', 'J', 'Q', 'K']def printC(n): if(C[0] == '小王' or C[len(C)-1] == '大王'...原创 2018-12-26 10:18:19 · 1154 阅读 · 0 评论 -
凯撒加密和栅栏加密 python
凯撒加密 # lzdqwbrxdef casearDecrypt(ciphertext, source_char, destination_char, list_all): if list_all == True: for offset in range(1, 27): convertChar(offset)...转载 2017-02-03 21:00:07 · 1913 阅读 · 0 评论 -
python 计算txt文本词频率
如: “123—-123, 567—-567, ……..”import refrom collections import Counterwith open('1 (2).txt') as f: pass_list = f.read().split(&quot;\n&quot;)for i in range(0, len(pass_list)): r = re.search(&quot;-...原创 2018-07-29 14:11:29 · 1629 阅读 · 1 评论 -
python 网页文字提取
提取网页指定内容用的import requestsfrom bs4 import BeautifulSoupimport reurl = "https://xxxxxx.html"html = requests.get(url).textbs = BeautifulSoup(html)users = bs.select('.c-author')for each in use...原创 2018-07-25 20:31:08 · 8858 阅读 · 2 评论 -
python str与byte转换 encode decode
具体内容可以查python3.6文档# str to bytekey = "aaa"r = str.encode(key)print(type(r))print(r)# byte to strkey2 = b"aaa"r = key2.decode()print(type(r))print(r)输出:<class 'bytes'>b'a...原创 2018-04-30 12:23:14 · 4103 阅读 · 0 评论 -
argparse 传参例子 python
# coding:utf-8'''参数测试'''import argparseparser = argparse.ArgumentParser()# 添加参数parser.add_argument('--foo', type=str, default="我是默认", help='默认帮助')# 如:原创 2018-01-24 18:10:32 · 1271 阅读 · 0 评论 -
快速排序 python
# 快速排序def partition(r,left,right): i = left j = right while(i<j): while(i<j and r[i]<=r[j]): # 右侧扫描 j -= 1 if i<j: r[i],r[j] = r[j],r[i]原创 2017-02-18 11:18:28 · 948 阅读 · 0 评论 -
装饰器(语法糖) python
# 传参装饰器def log(text): def decorator(func): def wraper(*args,**kw): print '%s %s' % (text,func.__name__) return func(*args,**kw) return wraper return de原创 2017-02-18 12:25:31 · 511 阅读 · 0 评论 -
时间戳to时间to字符串 python
import time# 时间转 strdef date2str(d): s = time.strftime("%Y-%m-%d", d) return s # 时间戳转换为时间def tamp2date(timestamp): d = time.localtime(timestamp) return d# str 转换时间戳def str2原创 2017-02-22 21:25:28 · 795 阅读 · 0 评论 -
合并文件 python
import os# 获得目录下的所有文件(不包含文件夹)def get_path_filename(path,suffix): l = [] l2 = [] # 处理后的列表 def VisitDir(arg, dirname, names): for filespath in names:原创 2017-02-23 16:34:35 · 413 阅读 · 0 评论 -
pip的使用 python
pip wheel -w wheel-requests requests==2.12.3 //生成 wheelwheel-requests 是目录(当前)requests==2.12.3 是 包名加版本号 (必须)pip freeze >requirements.txt//生成依赖文件原创 2017-04-01 11:19:57 · 289 阅读 · 0 评论 -
python 计算程序剩余时间的小程序
# 计算爬虫剩余时间(根据程序剩余的个数 如 500->250)import time# 开始的值s_status0 = raw_input('input start value of status is 0: ')start_time = time.clock()print "_"*10print print printprint print printprint原创 2017-05-02 09:29:17 · 1961 阅读 · 0 评论 -
正则表达式
http://www.runoob.com/python/python-reg-expressions.htmlpublic class Re { /** * 如 s = "login?id=123" Re.match("id=(\\d+)",s) = 123 * @param re 正则表达式 * @param s 需要匹配的字符串 * @return 匹...原创 2016-12-09 13:04:00 · 320 阅读 · 0 评论 -
folium遇到的坑 不显示颜色
三个坑: 居然不显示分层的颜色(heatmap)很坑啊,网上查了很多资料,发现新版的folium的geo_json换了方法成了choropleth 还有一个坑 feature.id 这里 feature必须是第一个参数。 最后一个坑 su_lt_two['Zip']=su_lt_two['Zip'].astype(str) 读取csv时,例如‘Zip’字段的类型必须与geojson原创 2017-11-13 17:08:41 · 3302 阅读 · 3 评论 -
json输出键值对 python
数据:{ "2017-11-30": 990, "2017-12-01": 730, "2017-12-02": 620, "2017-12-03": 640, ...}import jsonwith open('fly.txt','r') as f: data = f.read()j = json.loads(data)for each in j原创 2017-11-30 16:56:00 · 5635 阅读 · 1 评论 -
机器学习笔记(7)逻辑回归
逻辑回归(logistic)实际上是线性回归推导出来的。而且是一种分类学习方法。由于简单的二分类0-1图像不连续,我们想找到一种连续且可微的函数替换他。logistic function 正是这阿样一个函数y=11+e−zy=\frac {1} {1 + e^{ - z}}看看图: 代码:# -*- coding: utf-8 -*-from sklearn import datasetsim原创 2017-11-23 15:22:33 · 448 阅读 · 0 评论 -
反向代理 python twisted
实现反向代理,模拟nginxfrom twisted.internet import reactorfrom twisted.web import proxy, server, staticroot = static.File("./")root.putChild('api', proxy.ReverseProxyResource('127.0.0.1', 9000, '/api'))site原创 2017-11-27 19:07:16 · 2918 阅读 · 2 评论 -
二分查找算法 python
def binary_search(l,num): low,high = 0,len(l) while low <= high: print low, high mid = (low+high)/2 if num < l[mid]: high = mid - 1 elif num > l[mid原创 2017-02-17 10:23:58 · 478 阅读 · 0 评论