上一页 1 ··· 56 57 58 59 60 61 62 63 64 ··· 68 下一页
摘要: 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 阅读(4024) 评论(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 阅读(4582) 评论(0) 推荐(0) 编辑
摘要: 将结尾的Road用Rd.替换 阅读全文
posted @ 2018-11-14 10:13 anobscureretreat 阅读(4844) 评论(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 阅读(147) 评论(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 阅读(373) 评论(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 阅读(832) 评论(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 阅读(1425) 评论(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 阅读(1598) 评论(0) 推荐(0) 编辑
摘要: 例子一 输出: 例子二: 输出: 阅读全文
posted @ 2018-11-14 00:56 anobscureretreat 阅读(172) 评论(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 阅读(372) 评论(0) 推荐(0) 编辑
摘要: crontab -e 输出如下 然后就会打开一个文件,什么都不用做,直接保存,保存方式类似vim 再次crontab -l ,就会显示出定时任务了 阅读全文
posted @ 2018-11-14 00:05 anobscureretreat 阅读(3264) 评论(0) 推荐(0) 编辑
摘要: #Create a set seta = set([5, 10, 3, 15, 2, 20]) #Find maximum value print(max(seta)) #Find minimum value print(min(seta)) 阅读全文
posted @ 2018-11-13 10:26 anobscureretreat 阅读(3962) 评论(0) 推荐(0) 编辑
摘要: #Intersection setx = set(["green", "blue"]) sety = set(["blue", "yellow"]) setz = setx & sety print(setz) 阅读全文
posted @ 2018-11-13 10:22 anobscureretreat 阅读(303) 评论(0) 推荐(0) 编辑
摘要: #Union setx = set(["green", "blue"]) sety = set(["blue", "yellow"]) seta = setx | sety print(seta) 阅读全文
posted @ 2018-11-13 10:20 anobscureretreat 阅读(221) 评论(0) 推荐(0) 编辑
摘要: setx = set(["apple", "mango"]) sety = set(["mango", "orange"]) #Symmetric difference setc = setx ^ sety print(setc) 阅读全文
posted @ 2018-11-13 10:17 anobscureretreat 阅读(336) 评论(0) 推荐(0) 编辑
摘要: setp = set(["Red", "Green"]) setq = setp.copy() print(setq) setp.clear() print(setq) 阅读全文
posted @ 2018-11-12 22:37 anobscureretreat 阅读(1353) 评论(0) 推荐(0) 编辑
摘要: #A new empty set color_set = set() color_set.add("Red") print(color_set) #Add multiple items color_set.update(["blue","blue", "Green"]) print(color_set) 阅读全文
posted @ 2018-11-12 22:31 anobscureretreat 阅读(7703) 评论(0) 推荐(0) 编辑
摘要: #create a tuple l = [(1,2), (3,4), (8,9)] print(list(zip(*l))) 阅读全文
posted @ 2018-11-12 22:27 anobscureretreat 阅读(4574) 评论(0) 推荐(0) 编辑
摘要: #create a tuple tuplex = 4, 8, 3 print(tuplex) n1, n2, n3 = tuplex #unpack a tuple in variables print(n1 + n2 + n3) #the number of variables must be equal to the number of items of the tuple n1, n2... 阅读全文
posted @ 2018-11-12 22:25 anobscureretreat 阅读(541) 评论(0) 推荐(0) 编辑
摘要: #create a tuple tuplex = (2, 4, 3, 5, 4, 6, 7, 8, 6, 1) #used tuple[start:stop] the start index is inclusive and the stop index _slice = tuplex[3:5] #is exclusive print(_slice) #if the start index ... 阅读全文
posted @ 2018-11-12 22:22 anobscureretreat 阅读(1888) 评论(0) 推荐(0) 编辑
摘要: #create a tuple x = ("w3resource") # Reversed the tuple y = reversed(x) print(tuple(y)) #create another tuple x = (5, 10, 15, 20) # Reversed the tuple y = reversed(x) print(tuple(y)) 阅读全文
posted @ 2018-11-12 22:20 anobscureretreat 阅读(2200) 评论(0) 推荐(0) 编辑
摘要: #create a tuple tuplex = "w", "j" ,"c", "e" print(tuplex) #tuples are immutable, so you can not remove elements #using merge of tuples with the + operator you can remove an item and it will create ... 阅读全文
posted @ 2018-11-12 22:17 anobscureretreat 阅读(3882) 评论(0) 推荐(0) 编辑
摘要: 编译指定包 使用上述命令后catkin_make会一直编译上面那个包,想要编译全部包,使用 阅读全文
posted @ 2018-11-12 21:18 anobscureretreat 阅读(352) 评论(0) 推荐(0) 编辑
摘要: sudo apt-get install ros-kinetic-robot-pose-publisher 阅读全文
posted @ 2018-11-12 21:15 anobscureretreat 阅读(768) 评论(0) 推荐(0) 编辑
摘要: sudo apt-get install ros-kinetic-rosbridge-server 阅读全文
posted @ 2018-11-12 21:14 anobscureretreat 阅读(1216) 评论(0) 推荐(0) 编辑
摘要: 第一种 原因,/etc/hostname 中的hostname 与/etc/hosts 里面的不对应,导致无法解析 将两个文件的hostname改成一样的即可。 /etc/hostname /etc/hosts 第二种 或者:/etc/hosts 在127.0.0.1 localhost 后面加上主 阅读全文
posted @ 2018-11-12 19:35 anobscureretreat 阅读(510) 评论(0) 推荐(0) 编辑
摘要: #create a tuple tuplex = 2, 4, 5, 6, 2, 3, 4, 4, 7 print(tuplex) #return the number of times it appears in the tuple. count = tuplex.count(4) print(count) 阅读全文
posted @ 2018-11-12 10:41 anobscureretreat 阅读(818) 评论(0) 推荐(0) 编辑
摘要: #create a tuple tuplex = tuple("index tuple") print(tuplex) #get index of the first item whose value is passed as parameter index = tuplex.index("p") print(index) #define the index from which you w... 阅读全文
posted @ 2018-11-12 10:37 anobscureretreat 阅读(4181) 评论(0) 推荐(0) 编辑
摘要: from copy import deepcopy #create a tuple tuplex = ("HELLO", 5, [], True) print(tuplex) #make a copy of a tuple using deepcopy() function tuplex_clone = deepcopy(tuplex) tuplex_clone[2].append(50) ... 阅读全文
posted @ 2018-11-12 10:31 anobscureretreat 阅读(153) 评论(0) 推荐(0) 编辑
摘要: tup = ('e', 'x', 'e', 'r', 'c', 'i', 's', 'e', 's') str = ''.join(tup) print(str) 阅读全文
posted @ 2018-11-12 10:25 anobscureretreat 阅读(3943) 评论(0) 推荐(0) 编辑
摘要: #create a tuple tuplex = ((2, "w"),(3, "r")) print(dict((y, x) for x, y in tuplex)) 阅读全文
posted @ 2018-11-12 10:22 anobscureretreat 阅读(4343) 评论(0) 推荐(0) 编辑
摘要: #create a list l = [("x", 1), ("x", 2), ("x", 3), ("y", 1), ("y", 2), ("z", 1)] d = {} for a, b in l: d.setdefault(a, []).append(b) print (d) 阅读全文
posted @ 2018-11-12 10:17 anobscureretreat 阅读(982) 评论(0) 推荐(0) 编辑
摘要: 例一 例二 输出: 阅读全文
posted @ 2018-11-11 12:23 anobscureretreat 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 输出: 阅读全文
posted @ 2018-11-11 12:22 anobscureretreat 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 第一种 第二种 shell下的一句话脚本,在命令行执行以下语句 阅读全文
posted @ 2018-11-10 15:37 anobscureretreat 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 这个也是python彪悍的特性. 自省就是面向对象的语言所写的程序在运行时,所能知道对象的类型.简单一句就是运行时能够获得对象的类型.比如type(),dir(),getattr(),hasattr(),isinstance(). a = [1,2,3] b = {'a':1,'b':2,'c':3 阅读全文
posted @ 2018-11-10 00:43 anobscureretreat 阅读(114) 评论(0) 推荐(0) 编辑
摘要: a = 1 def fun(a): a = 2 fun(a) print a # 1 a = [] def fun(a): a.append(1) fun(a) print a # [1] 阅读全文
posted @ 2018-11-10 00:32 anobscureretreat 阅读(122) 评论(0) 推荐(0) 编辑
摘要: ⾸先我们来理解下Python中的函数 def hi(name="yasoob"): return "hi " + name print(hi()) # output: 'hi yasoob' # 我们甚⾄可以将⼀个函数赋值给⼀个变量,⽐如 greet = hi # 我们这⾥没有在使⽤⼩括号,因为我们并不是在调⽤hi函数 # ⽽是在将它放在greet变量⾥头。我们尝试运⾏下这个 print(g... 阅读全文
posted @ 2018-11-09 22:47 anobscureretreat 阅读(1278) 评论(0) 推荐(0) 编辑
摘要: def hi(name="yasoob"): def greet(): return "now you are in the greet() function" def welcome(): return "now you are in the welcome() function" if name == "yasoob": ... 阅读全文
posted @ 2018-11-09 22:46 anobscureretreat 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 输出: 阅读全文
posted @ 2018-11-09 22:45 anobscureretreat 阅读(155) 评论(0) 推荐(0) 编辑
上一页 1 ··· 56 57 58 59 60 61 62 63 64 ··· 68 下一页