小笔记 - python
1,查找列表中某个值的位置(python)
p=list.index(value) list为列表的名字 value为查找的值 p为value在list的位置
2,正则-移除字符串两侧空格
re.sub(' ', '', attrValueString)
3,正则-字符串转列表
attrValue = “1.0, 2.2, 3, 5.04”
re.findall('[a-z.0-9]+', attrValue)
4,转换秒到时间格式。
1 def convertseconds(self, seconds) : 2 m, s = divmod( int(seconds), 60) 3 h, m = divmod(m, 60) 4 formatsecond = "%d:%02d:%02d"%(h, m, s) 5 return formatsecond
浙公网安备 33010602011771号