![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
wilson_go
这个作者很懒,什么都没留下…
展开
-
pandas处理csv文件
机器学习离不开数据,数据分析离不开pandas。昨天感受了一下,真的方便。按照一般的使用过程,将pandas的常用方法说明一下。首先,我们拿到一个excel表,我们将之另存为csv文件。因为文件是实验室的资源,我就不分享了。首先是文件读取def load_csv(filename): data=pd.read_csv(filename) data = data.drop(da...原创 2018-10-27 16:36:20 · 1383 阅读 · 0 评论 -
TypeError: slice indices must be integers or None or have an __index__ method
TypeError: slice indices must be integers or None or have an __index__ method该错误主要是因为下标不支持浮点数所导致的例如:len(alist)/2得到的类型为浮点数这和Python2还有很多其他语言不一样,Python2还有很多其他语言大多数会将该结果转化为整数类型,但是在python3中该类型为浮点数类型,因...原创 2019-06-17 11:05:54 · 315 阅读 · 0 评论 -
python爬虫使用Cookie登录
将Cookie写在header头部# coding:utf-8import requestsfrom bs4 import BeautifulSoupcookie = '''cisession=19dfd70a27ec0eecf1fe3fc2e48b7f91c7c83c60;CNZZDATA1000201968=1815846425-1478580135-https%253A%252F%...原创 2019-03-28 17:36:38 · 1590 阅读 · 0 评论 -
python中URL常见的header
user_agent = ["Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50","Mozilla/5.0 (Windows; U; Windows NT 6.1; en-us) AppleWebKit...原创 2019-04-07 17:45:06 · 3354 阅读 · 0 评论 -
python文件切割
fopen = open('cleandingdian.csv', 'r')diff_line = fopen.readlines()line_list = []for line in diff_line: line_list.append(line[:len(line)-1])print(line_list)diff_match_split = [line_list[i:i...原创 2019-04-01 10:49:14 · 897 阅读 · 0 评论 -
python中的ThreadPoolExecutor
#!/bin/env python3import requestsimport datetimeimport threadingimport csvimport jsonimport randomfrom concurrent.futures import ThreadPoolExecutorpool = ThreadPoolExecutor(16)threadLocal =...原创 2019-09-27 23:05:22 · 607 阅读 · 0 评论 -
python工具方法
isExists = os.path.exists(down_path)if not isExists: os.makedirs(down_path) print(down_path + ' 创建成功')else: # 如果目录存在则不创建,并提示目录已存在 print(down_path + ' 目录已存在')查看文件是否存在import request...原创 2019-03-31 14:56:30 · 192 阅读 · 0 评论 -
python中爬虫通用方法
import os url = 'http://www.**.net/images/logo.gif'filename = os.path.basename(url)print(filename)python 从url中提取文件名原创 2019-03-21 10:31:32 · 281 阅读 · 0 评论