上一页 1 2 3 4 5 6 7 8 9 ··· 12 下一页
摘要: import pickle """以前的文件写入,只能写入字符串,如果希望把任意数据对象(数字、列表等)写入文件, 取出来的时候数据类型不变,就用到pickle了 """ # shop_list = ["eggs", "apple", "peach"] # with open('/tmp/shop. 阅读全文
posted @ 2019-05-30 10:48 hejp 阅读(143) 评论(0) 推荐(0) 编辑
摘要: import os os.getcwd() # 显示当前路径 os.listdir() # ls -a os.listdir('/tmp') # ls -a /tmp os.mkdir('/tmp/mydemo') # mkdir /tmp/mydemo os.chdir('/tmp/mydemo' 阅读全文
posted @ 2019-05-30 10:13 hejp 阅读(144) 评论(0) 推荐(0) 编辑
摘要: import time t = time.localtime() # 返回当前时间的九元组 time.gmtime() # 返回格林威治0时区当前时间的九元组 time.time() # 常用,与1970-1-1 8:00之间的秒数,时间戳 time.mktime(t) # 把九元组时间转成时间戳 time.sleep(1) time.asctime() # 如果有参数,是九元组形式... 阅读全文
posted @ 2019-05-29 17:07 hejp 阅读(134) 评论(0) 推荐(0) 编辑
摘要: import time result = 0 start = time.time() # 返回运算前时间戳 for i in range(10000000): result += i end = time.time() # 返回运算后时间戳 print(result) print(end - start) 结果输出: 阅读全文
posted @ 2019-05-29 17:04 hejp 阅读(174) 评论(0) 推荐(0) 编辑
摘要: import getpass userdb = {} def register(): username = input('username: ') if username in userdb: print('%s already exits.' % username) else: password = input('password: ... 阅读全文
posted @ 2019-05-29 16:33 hejp 阅读(293) 评论(0) 推荐(0) 编辑
摘要: with open('./passwd') as fobj: aset = set(fobj) print(aset) with open('./mima') as fobj: bset = set(fobj) print(bset) with open('diff.txt', 'w') as fobj: fobj.writelines(aset -... 阅读全文
posted @ 2019-05-29 15:23 hejp 阅读(138) 评论(0) 推荐(0) 编辑
摘要: # 集合相当于是无值的字典,所以也用{}表示 myset = set('hello') len(myset) for ch in myset: print(ch) aset = set('abc') bset = set('cde') aset & bset # 交集 aset.intersection(bset) # 交集 aset | bset # 并集 aset.union... 阅读全文
posted @ 2019-05-29 09:53 hejp 阅读(156) 评论(0) 推荐(0) 编辑
摘要: adict = dict([('name', 'bob'),('age', 30)]) len(adict) hash(10) # 判断给定的数据是不是不可变的,不可变数据才能作为key adict.keys() adict.values() adict.items() # get方法常用,重要 adict.get('name') # 取出字典中name对应的value,如果没有返回None... 阅读全文
posted @ 2019-05-29 09:47 hejp 阅读(158) 评论(0) 推荐(0) 编辑
摘要: Nginx配置参数优化:1. 隐藏版本号:server_tokens off; 2. 修改nginx默认用户组:user www-data; 3. 修改worker_processes的进程数:等于CPU个数。/proc/cpuinfo可以查看CPU个数:worker_processes 16; 4 阅读全文
posted @ 2019-05-24 16:03 hejp 阅读(298) 评论(0) 推荐(0) 编辑
摘要: 部门内网开发环境 kubernetes 二进制安装:kubernetes-1.13.1 + etcd-3.3.10 + flanneld-0.10集群部署 1.前提准备:K8S服务部署安装:172.16.14.110 k8s-master172.16.14.112 k8s-node1172.16.1 阅读全文
posted @ 2019-05-24 11:29 hejp 阅读(416) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 12 下一页