随笔分类 -  python

Shell #*/ 和 %/*
摘要:#!/bin/bash i="this/is/a/path.config" name=${i#*/} path=${i%/*} echo $name echo $path is/a/path.config this/is/a 阅读全文

posted @ 2017-08-23 15:08 TMatrix52 阅读(360) 评论(0) 推荐(0) 编辑

[转载] python必碰到的问题---encode与decode,中文乱码
摘要:阅读来源: 字符串在Python内部的表示是unicode编码,因此,在做编码转换时,通常需要以unicode作为中间编码,即先将其他编码的字符串解码(decode)成unicode,再从unicode编码(encode)成另一种编码。 decode的作用是将其他编码的字符串转换成unicode编码 阅读全文

posted @ 2017-08-23 14:23 TMatrix52 阅读(128) 评论(0) 推荐(0) 编辑

Python爬虫利器三之lxml库以及Xpath语法
摘要:转自 阅读全文

posted @ 2017-08-08 11:39 TMatrix52 阅读(101) 评论(0) 推荐(0) 编辑

python linecache模块读取文件的方法
摘要:转自: 阅读全文

posted @ 2017-07-22 09:42 TMatrix52 阅读(318) 评论(0) 推荐(0) 编辑

Python 字符串中 startswith()方法
摘要:Python startswith() 方法用于检查字符串是否是以指定子字符串开头,如果是则返回 True,否则返回 False。如果参数 beg 和 end 指定值,则在指定范围内检查。 结果: 阅读全文

posted @ 2017-07-15 22:27 TMatrix52 阅读(254) 评论(0) 推荐(0) 编辑

Python中的filter()函数的用法
摘要:转载自:脚本之家 Python内建的filter()函数用于过滤序列。 和map()类似,filter()也接收一个函数和一个序列。和map()不同的时,filter()把传入的函数依次作用于每个元素,然后根据返回值是True还是False决定保留还是丢弃该元素。 例如,在一个list中,删掉偶数, 阅读全文

posted @ 2017-07-15 22:17 TMatrix52 阅读(541) 评论(0) 推荐(0) 编辑

python sort、sorted高级排序技巧
摘要:文章转载自:脚本之家 Python list内置sort()方法用来排序,也可以用python内置的全局sorted()方法来对可迭代的序列排序生成新的序列。 1)排序基础 简单的升序排序是非常容易的。只需要调用sorted()方法。它返回一个新的list,新的list的元素基于小于运算符(__lt 阅读全文

posted @ 2017-07-15 17:14 TMatrix52 阅读(3891) 评论(0) 推荐(1) 编辑

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示