- 博客(2)
- 资源 (3)
- 收藏
- 关注
原创 python高级应用100例
一、推导式1、列表推导式:求[1, 2, 3, 4, 5, 6]中的元素大于3的数的平方。_list = [ a * a for a in [1,2,3,4,5,6] if a > 3]2、集合推导式:去除[1, 2, 3, 4, 2, 3, 5, 6, 4]中的重复且无法整除2的元素。_list =[1, 2, 3, 4, 2, 3, 5, 6, 4]3、字...
2020-02-02 17:47:18 1963 1
原创 python操作技巧(一)
1、读取文件:去除空行,'\n'# splitlines():去除str中的'\n'with open('assets/cityCode.txt', 'r') as f: all_lines = [line for line in f.read().splitlines() if line]
2020-02-02 17:44:26 100
cityCode.txt
2020-01-28
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人