随笔分类 -  Python

摘要:Python实现图的经典DFS、BFS、Dijkstra、Floyd、Prim、Kruskal算法 阅读全文
posted @ 2020-09-21 14:08 salami_china 阅读(261) 评论(0) 推荐(0) 编辑
摘要:原文链接:Python实现BFS和DFS 广度优先搜索算法(英语:Breadth-First-Search,缩写为BFS),又译作宽度优先搜索,或横向优先搜索,是一种图形搜索算法。简单的说,BFS是从根节点开始,沿着树的宽度遍历树的节点。如果所有节点均被访问,则算法中止。 深度优先搜索算法(英语:D 阅读全文
posted @ 2020-09-21 13:51 salami_china 阅读(608) 评论(0) 推荐(0) 编辑
摘要:原文链接:https://opendev.org/starlingx/ha/src/commit/045a37c672a92f1412629a176f51183c88882e61/service-mgmt-api/sm-api/sm_api/cmd/api.py make_server 接口配置 h 阅读全文
posted @ 2020-06-18 14:09 salami_china 阅读(206) 评论(0) 推荐(0) 编辑
摘要:num = [1,2,3,4,5,6,7,8,9] for i in range(0, num.__len__())[::-1]: print num[i] 阅读全文
posted @ 2020-06-10 10:21 salami_china 阅读(1722) 评论(0) 推荐(0) 编辑
摘要:原文链接: python基础-文件读写'r' 和 'rb'区别 一、Python文件读写的几种模式: r,rb,w,wb 那么在读写文件时,有无b标识的的主要区别在哪里呢? 1、文件使用方式标识 'r':默认值,表示从文件读取数据。'w':表示要向文件写入数据,并截断以前的内容'a':表示要向文件写 阅读全文
posted @ 2020-04-27 17:59 salami_china 阅读(749) 评论(0) 推荐(0) 编辑
摘要:原文链接:https://www.cnblogs.com/hushaojun/p/4533241.html >>> import os >>> os.path.exists('d:/assist') True >>> os.path.exists('d:/assist/getTeacherList. 阅读全文
posted @ 2020-04-26 11:05 salami_china 阅读(20190) 评论(1) 推荐(0) 编辑
摘要:md5是一种常见不可逆加密算法,使用简单,计算速度快,在很多场景下都会用到,比如:给用户上传的文件命名,数据库中保存的用户密码,下载文件后检验文件是否正确等。下面讲解在python中如何使用md5算法。 一、计算字符串的md5值 #!/usr/bin/env python # -*- coding: 阅读全文
posted @ 2020-04-24 20:17 salami_china 阅读(968) 评论(0) 推荐(0) 编辑
摘要:原文链接:http://networkbit.ch/python-jinja-template/ template.txt如下: hostname {{ name }} interface Loopback1 ip address 10.1.1.{{ id }} 255.255.255.255 {% 阅读全文
posted @ 2020-04-23 15:52 salami_china 阅读(302) 评论(0) 推荐(0) 编辑
摘要:需求目标 执行Python程序的时候在控制台输出内容的时候只显示一行,然后自动刷新内容,像这样: Downloading File FooFile.txt [47%] 而不是这样: Downloading File FooFile.txt [47%] Downloading File FooFile 阅读全文
posted @ 2020-04-22 10:24 salami_china 阅读(550) 评论(0) 推荐(0) 编辑
摘要:参考文档: https://www.cnblogs.com/schut/p/10410087.html 清华大学:https://pypi.tuna.tsinghua.edu.cn/simple 阿里云:http://mirrors.aliyun.com/pypi/simple/ 豆瓣:http:/ 阅读全文
posted @ 2020-04-04 17:24 salami_china 阅读(202) 评论(0) 推荐(0) 编辑
摘要:import os env_dist = os.environ # environ是在os.py中定义的一个dict environ = {} print env_dist.get('JAVA_HOME') print env_dist['JAVA_HOME'] # 打印所有环境变量,遍历字典 fo 阅读全文
posted @ 2020-03-07 21:25 salami_china 阅读(313) 评论(0) 推荐(0) 编辑
摘要:原文链接:https://linuxops.org/blog/python/prettytable.html #!/usr/bin/python #**coding:utf-8** import sys from prettytable import PrettyTable reload(sys) 阅读全文
posted @ 2020-03-06 13:58 salami_china 阅读(1240) 评论(0) 推荐(0) 编辑
摘要:1.下载地址 https://pypi.org/project/pypcap/#history 2.下载后,解压并制作rpm tar -xvf pypcap-1.2.3.tar.gz python setup.py bdist_rpm 阅读全文
posted @ 2020-03-05 22:58 salami_china 阅读(94) 评论(0) 推荐(0) 编辑
摘要:Python方法oslo_service.loopingcall.LoopingCallDone代码示例 demo: from oslo_service import loopingcall def _wait_for_image_state(): global num num = 0 def _w 阅读全文
posted @ 2020-02-16 18:49 salami_china 阅读(413) 评论(0) 推荐(0) 编辑
摘要:参考文章 ceph的python_api文档: http://docs.ceph.com/docs/master/rados/api/python/ 连接ceph集群 import rados cluster = rados.Rados(conffile='/etc/ceph/ceph.conf') 阅读全文
posted @ 2020-01-07 10:23 salami_china 阅读(2893) 评论(0) 推荐(0) 编辑
摘要:问题:ImportError: No module named git 解决:yum install GitPython 阅读全文
posted @ 2019-12-30 13:33 salami_china 阅读(3223) 评论(0) 推荐(0) 编辑
摘要:import IPy >>>'192.168.1.100' in IPy.IP('192.168.1.0/24') is True >>>'192.168.1.0/24' in IPy.IP('192.168.0.0/16') is True >>>'192.168.1.0/24' in IPy.I 阅读全文
posted @ 2019-12-20 15:49 salami_china 阅读(3318) 评论(0) 推荐(0) 编辑
摘要:原文链接:https://centos.pkgs.org/7/forensics-x86_64/python2-dpkt-1.9.2-2.el7.noarch.rpm.html 1.Download cert-forensics-tools-release-el7 rpm: https://fore 阅读全文
posted @ 2019-12-18 19:41 salami_china 阅读(390) 评论(0) 推荐(0) 编辑
摘要:原文链接:https://www.bigdatasafe.org/post/41334.html 简介Thrift最初由Facebook研发,主要用于各个服务之间的RPC通信,支持跨语言,常用的语言比如C++, Java, Python, PHP, Ruby, Erlang, Perl, Haske 阅读全文
posted @ 2019-12-11 18:45 salami_china 阅读(387) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示