摘要:
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)
摘要:
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)
posted @ 2018-11-14 10:13
anobscureretreat
阅读(4851)
推荐(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)
摘要:
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)
摘要:
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)
摘要:
#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)
摘要:
// 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)
摘要:
例子一 输出: 例子二: 输出:
阅读全文
posted @ 2018-11-14 00:56
anobscureretreat
阅读(179)
推荐(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)
摘要:
crontab -e 输出如下 然后就会打开一个文件,什么都不用做,直接保存,保存方式类似vim 再次crontab -l ,就会显示出定时任务了
阅读全文
posted @ 2018-11-14 00:05
anobscureretreat
阅读(3340)
推荐(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
阅读(3995)
推荐(0)
摘要:
#Intersection setx = set(["green", "blue"]) sety = set(["blue", "yellow"]) setz = setx & sety print(setz)
阅读全文
posted @ 2018-11-13 10:22
anobscureretreat
阅读(308)
推荐(0)
摘要:
#Union setx = set(["green", "blue"]) sety = set(["blue", "yellow"]) seta = setx | sety print(seta)
阅读全文
posted @ 2018-11-13 10:20
anobscureretreat
阅读(230)
推荐(0)
摘要:
setx = set(["apple", "mango"]) sety = set(["mango", "orange"]) #Symmetric difference setc = setx ^ sety print(setc)
阅读全文
posted @ 2018-11-13 10:17
anobscureretreat
阅读(344)
推荐(0)
摘要:
setp = set(["Red", "Green"]) setq = setp.copy() print(setq) setp.clear() print(setq)
阅读全文
posted @ 2018-11-12 22:37
anobscureretreat
阅读(1363)
推荐(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
阅读(7716)
推荐(0)
摘要:
#create a tuple l = [(1,2), (3,4), (8,9)] print(list(zip(*l)))
阅读全文
posted @ 2018-11-12 22:27
anobscureretreat
阅读(4588)
推荐(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
阅读(551)
推荐(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
阅读(1907)
推荐(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
阅读(2220)
推荐(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
阅读(3907)
推荐(0)
摘要:
编译指定包 使用上述命令后catkin_make会一直编译上面那个包,想要编译全部包,使用
阅读全文
posted @ 2018-11-12 21:18
anobscureretreat
阅读(384)
推荐(0)
摘要:
sudo apt-get install ros-kinetic-robot-pose-publisher
阅读全文
posted @ 2018-11-12 21:15
anobscureretreat
阅读(792)
推荐(0)
摘要:
sudo apt-get install ros-kinetic-rosbridge-server
阅读全文
posted @ 2018-11-12 21:14
anobscureretreat
阅读(1239)
推荐(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
阅读(528)
推荐(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
阅读(828)
推荐(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
阅读(4204)
推荐(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
阅读(161)
推荐(0)
摘要:
tup = ('e', 'x', 'e', 'r', 'c', 'i', 's', 'e', 's') str = ''.join(tup) print(str)
阅读全文
posted @ 2018-11-12 10:25
anobscureretreat
阅读(3961)
推荐(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
阅读(4371)
推荐(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
阅读(992)
推荐(0)
posted @ 2018-11-11 12:23
anobscureretreat
阅读(167)
推荐(0)
posted @ 2018-11-11 12:22
anobscureretreat
阅读(146)
推荐(0)
摘要:
第一种 第二种 shell下的一句话脚本,在命令行执行以下语句
阅读全文
posted @ 2018-11-10 15:37
anobscureretreat
阅读(153)
推荐(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
阅读(120)
推荐(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
阅读(130)
推荐(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
阅读(1288)
推荐(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
阅读(192)
推荐(0)
posted @ 2018-11-09 22:45
anobscureretreat
阅读(160)
推荐(0)