1、sys.argv获得外部参数
sys.argv[0]代表文件本身
2、类中的self
self是对象的实例,如变量的实例,函数的实例
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: antcolonies
class Person(object):
def __init__(self, name, lang, website):
self.name = name
self.lang = lang
self.website = website
print('self: ', self)
print('type of self: ', type(self))
'''
未实例化时,运行程序,构造方法没有运行
'''
p = Person('Tim', 'English', 'www.universal.com')
得:
('self: ', <__main__.Person object at 0x7f13bf784450>)
('type of self: ', <class '__main__.Person'>)
Python类中的__init__() 和 self 的解析
3、
str.lower( ) 转换字符串中所有大写字符为小写。
4、rospy.signal_shutdown(reason)
- 初始化节点关闭
- reason 为关闭理由,字符串内容。
5、rospy.spin()
保持节点一直运行,直到节点关闭。
6、opencv函数
frgb=open('rgb.txt','a')
frgb.write(t+" "+filename+'\n')
rgb.txt文件,a追加模式
7、矩阵建立
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: antcolonies
from numpy import * #导入numpy的库函数
import numpy as np #使用numpy时,需要以np.开头
a1=np.array([[1,2,3],
[1,2,3]])
m=mat(a1) #建立矩阵
a2=np.array([4,5,6])
n=mat(a2)
def mask_depth(a):
print a.shape[0] #返回行数
print a.shape[1] #返回列数
return
mask_depth(m)