随笔分类 -  Python

摘要:测试示例: >>>x = set('runoob') >>> y = set('google') >>> x, y (set(['b', 'r', 'u', 'o', 'n']), set(['e', 'o', 'g', 'l'])) # 重复的被删除 >>> x & y # 交集 set(['o' 阅读全文
posted @ 2019-11-12 14:40 salami_china 阅读(172) 评论(0) 推荐(0)
摘要:错误信息: [root@wangjq networking-mirror]# python setup.py install /usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: ' 阅读全文
posted @ 2019-11-09 16:18 salami_china 阅读(2503) 评论(0) 推荐(1)
摘要:root@ostack01:~# python Python 2.7.12 (default, Nov 19 2018, 06:48:02) [GCC 5.4.0 20160609] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import yaml >>> yaml.__ 阅读全文
posted @ 2019-09-09 18:36 salami_china 阅读(1935) 评论(0) 推荐(0)
摘要:原文链接:https://blog.51cto.com/wenguonideshou/2083301 配置好Python3.6和pip3安装EPEL和IUS软件源 安装Python3.6 创建python3连接符 安装pip3 创建pip3链接符 阅读全文
posted @ 2019-09-04 21:55 salami_china 阅读(2583) 评论(0) 推荐(0)
摘要:python setup.py sdist bdist_wheel || true 阅读全文
posted @ 2019-07-31 09:58 salami_china 阅读(964) 评论(0) 推荐(0)
摘要:1.检查 python setup.py check 2.打包 python setup.py sdist bdist_wheel || true 阅读全文
posted @ 2019-05-17 10:59 salami_china 阅读(6000) 评论(0) 推荐(1)
摘要:1 import json 2 3 result = response.read() 4 result.decode('utf-8') 5 jsonData = json.loads(result) 阅读全文
posted @ 2019-03-04 10:55 salami_china 阅读(3037) 评论(0) 推荐(0)
摘要:IPv6 转 十进制: 十进制 转 IPv6: 阅读全文
posted @ 2019-02-18 10:00 salami_china 阅读(3257) 评论(0) 推荐(0)
摘要:1 >>> import numpy as np 2 >>> a = np.random.randint(-5, 5, (5, 5)) 3 >>> a 4 array([[-4, -4, -5, 2, 1], 5 [-1, -2, -1, 3, 3], 6 [-1, -2, 3, -5, 3], 7 [ 0, -3, -5, ... 阅读全文
posted @ 2019-02-01 14:01 salami_china 阅读(12040) 评论(0) 推荐(0)
摘要:原文:Python获取秒级时间戳与毫秒级时间戳 1、获取秒级时间戳与毫秒级时间戳 返回 2、将日期转为秒级时间戳 返回 3、将秒级时间戳转为日期 返回 阅读全文
posted @ 2019-01-16 16:35 salami_china 阅读(2356) 评论(0) 推荐(1)
摘要:1 #! /bin/python 2 3 filename='setup.ini' 4 lines=[] 5 with open(filename,'r') as f: 6 lines=f.readlines() 7 lines[1]='namespace = qmone-33c49600-4c22-486d-a397-e4f02bcdcf18' + '\n' 8 li... 阅读全文
posted @ 2018-12-19 15:28 salami_china 阅读(2006) 评论(0) 推荐(0)
摘要:1 #! /bin/python 2 3 def ip2decimalism(ip): 4 dec_value = 0 5 v_list = ip.split('.') 6 v_list.reverse() 7 t = 1 8 for v in v_list: 9 dec_value += int(v) * t 10 ... 阅读全文
posted @ 2018-12-18 12:05 salami_china 阅读(1345) 评论(0) 推荐(0)
摘要:原文链接:http://www.cnblogs.com/whatisfantasy/p/6440585.html 1 概念梳理: 1.1 线程 线程是操作系统能够进行运算调度的最小单位。它被包含在进程之中,是进程中的实际运作单位。一条线程指的是进程中一个单一顺序的控制流,一个进程中可以并发多个线程, 阅读全文
posted @ 2018-12-11 10:24 salami_china 阅读(3184) 评论(0) 推荐(0)
摘要:使用python里的index 该方法同样适合于字符串: 但是对于数组或者字符串里面含有不止一个要检索的数字时,只会返回第一个元素的索引。 用这种方法可以判断某个元素在数组或字符串中是否只出现一次。 正序index + 逆序index = 数组或者字符串的长度-1 阅读全文
posted @ 2018-12-06 16:31 salami_china 阅读(13962) 评论(0) 推荐(0)
摘要:c = [-10,-5,0,5,3,10,15,-20,25] print c.index(min(c)) # 返回最小值 print c.index(max(c)) # 返回最大值 阅读全文
posted @ 2018-11-14 19:35 salami_china 阅读(9059) 评论(0) 推荐(1)
摘要:Python中判断list是否为空有以下两种方式: 方式一: 方式二: 以上两种方法均可以判断出 list_temp 列表是否是空列表,第二个方法要优于第一个方法,在Python中,False,0,'',[],{},()都可以视为假。 阅读全文
posted @ 2018-11-01 15:13 salami_china 阅读(4940) 评论(0) 推荐(0)
摘要:1 import socket 2 import uuid 3 4 # 获取主机名 5 hostname = socket.gethostname() 6 #获取IP 7 ip = socket.gethostbyname(hostname) 8 # 获取Mac地址 9 def get_mac_address(): 10 mac=uuid.UUID(int = uui... 阅读全文
posted @ 2018-11-01 09:04 salami_china 阅读(803) 评论(0) 推荐(0)
摘要:import socket print socket.gethostname() 阅读全文
posted @ 2018-09-29 18:41 salami_china 阅读(313) 评论(0) 推荐(0)
摘要:问题: 解决: 阅读全文
posted @ 2018-07-19 10:51 salami_china 阅读(11529) 评论(0) 推荐(0)
摘要:在开头加上 import sys reload(sys) sys.setdefaultencoding( "utf-8" ) Python自然调用ascii编码解码程序去处理字符流,当字符流不属于ascii范围内,就会抛出异常(ordinal not in range(128))。 所以解决方法就是 阅读全文
posted @ 2018-06-15 14:34 salami_china 阅读(967) 评论(0) 推荐(0)