摘要: python manage.py makemigrations python manage.py migrate 阅读全文
posted @ 2018-11-14 23:55 anobscureretreat 阅读(166) 评论(0) 推荐(0)
摘要: 有时我们需要将特定操作封装成服务,通过服务启动停止,例如nginx的启动停止,service nginx start 或者service nginx stop 下面我们将编写一个demo sudo vi test,建立一个service名称为test的服务 加入下面模版代码 可以根据需要编写star 阅读全文
posted @ 2018-11-14 22:28 anobscureretreat 阅读(1975) 评论(0) 推荐(0)
摘要: 执行命令 阅读全文
posted @ 2018-11-14 17:46 anobscureretreat 阅读(745) 评论(0) 推荐(0)
摘要: import re def end_num(string): #以一个数字结尾字符串 text = re.compile(r".*[0-9]$") if text.match(string): return True else: return False print(end_num('abcdef'... 阅读全文
posted @ 2018-11-14 10:24 anobscureretreat 阅读(4067) 评论(0) 推荐(0)
摘要: def is_decimal(num): import re #以数字开头,小数点后保留1位数字或两位数字或者没有小数部分 dnumre = re.compile(r"""^[0-9]+(\.[0-9]{1,2})?$""") result = dnumre.search(num) return bool(result) prin... 阅读全文
posted @ 2018-11-14 10:18 anobscureretreat 阅读(4626) 评论(0) 推荐(0)
摘要: 将结尾的Road用Rd.替换 阅读全文
posted @ 2018-11-14 10:13 anobscureretreat 阅读(4851) 评论(1) 推荐(1)
摘要: x = frozenset([1, 2, 3, 4, 5]) y = frozenset([3, 4, 5, 6, 7]) #如果x与y没有公共元素,返回true print(x.isdisjoint(y)) #返回x与y不一样的元素 print(x.difference(y)) #返回x与y并集 print(x | y) 阅读全文
posted @ 2018-11-14 10:10 anobscureretreat 阅读(152) 评论(0) 推荐(0)
摘要: setx = set(["apple", "mango"]) sety = set(["mango", "orange"]) setz = set(["mango"]) issubset = setx = sety print(issuperset) issubset = setz = setz print(issuperset) 阅读全文
posted @ 2018-11-14 10:01 anobscureretreat 阅读(375) 评论(0) 推荐(0)
摘要: num_set = set([0, 1, 3, 4, 5]) num_set.pop() print(num_set) num_set.pop() print(num_set) 阅读全文
posted @ 2018-11-14 09:57 anobscureretreat 阅读(847) 评论(0) 推荐(0)
摘要: #Create a new set num_set = set([0, 1, 2, 3, 4, 5]) #Discard number 4 num_set.discard(4) print(num_set) 阅读全文
posted @ 2018-11-14 09:55 anobscureretreat 阅读(1438) 评论(0) 推荐(0)
摘要: // xxx.h namespace A { #define xxx() xxxxx } // 在其他文件中,引入xxx.h文件,使用宏定义时,不需要加命名空间 // yyy.cpp #include "xxx.h" // somd code void func() { // 正确 xxx() } 阅读全文
posted @ 2018-11-14 00:58 anobscureretreat 阅读(1633) 评论(0) 推荐(0)
摘要: 例子一 输出: 例子二: 输出: 阅读全文
posted @ 2018-11-14 00:56 anobscureretreat 阅读(179) 评论(0) 推荐(0)
摘要: #!/bin/bash # 当/var/log/syslog大于68B时 if ! [ -f /var/log/syslog ] then echo "file not exist!" exit 1 fi if [ `ls -l /var/log/syslog|awk '{print $5}'` -gt $(68) ] then cat /var/log/syslog >>... 阅读全文
posted @ 2018-11-14 00:21 anobscureretreat 阅读(383) 评论(0) 推荐(0)
摘要: crontab -e 输出如下 然后就会打开一个文件,什么都不用做,直接保存,保存方式类似vim 再次crontab -l ,就会显示出定时任务了 阅读全文
posted @ 2018-11-14 00:05 anobscureretreat 阅读(3341) 评论(0) 推荐(0)