
python
csdn今天倒闭了吗
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Python 使用collections中的defaultdict创建字典
Python中可以使用collections中的defaultdict类实现创建进行统一初始化的字典。这里总结两种常用一点的初始化方式,分别是初始化为list和int。初始化为list示范代码: 1 2 3 4 5 6 7 8 9 #!/usr/bin/python from collectionsimport defaultdict s = [('yellow',...原创 2021-01-07 14:49:26 · 635 阅读 · 1 评论 -
Python获取字符串中特定的内容
有时需要多次调用提取字串内容的函数时,使用正则表达式不是很方便的时候,可以封装成函数调用。获取某字符后的int型:get_int_afterdef get_int_after(s, f): S = s.upper() F = f.upper() par = S.partition(F) int_str = "" for c in par[...原创 2018-10-29 14:52:00 · 25675 阅读 · 2 评论 -
使用pandas实现csv/excel sheet互相转换
1. xlsx to csv:import pandas as pddef xlsx_to_csv_pd(): data_xls = pd.read_excel('1.xlsx', index_col=0) data_xls.to_csv('1.csv', encoding='utf-8')if __name__ == '__main__': xlsx_to_...转载 2018-10-17 13:25:25 · 3215 阅读 · 0 评论 -
Python操作csv文件方法
DictReader字典读取csv指定列的内容想要读取“timer Start 8”的内容,或者获取该行其他列的信息,例如获取该行“RO timer expire”列对应的内容:with open(csvpath,'rb') as csvfile: reader = csv.DictReader(csvfile) for this_row in reader: ...原创 2018-11-08 10:55:08 · 389 阅读 · 0 评论 -
Python os模块方法汇总
1. os.path.abspath(path) 返回path规范化的绝对路径>>> os.path.abspath('test.csv') 'C:\\Python25\\test.csv' >>> os.path.abspath('c:\\test.csv') 'c:\\test.csv' >>> os.path.abs...原创 2018-11-08 11:43:51 · 455 阅读 · 0 评论