
python
四如君
这个作者很懒,什么都没留下…
展开
-
Python 字符串转元组,eval()
python字符串转元组eval()函数原创 2022-08-26 21:42:07 · 536 阅读 · 1 评论 -
记一下python windows环境怎么安装/激活/退出虚拟环境
python虚拟环境原创 2022-06-30 13:50:25 · 530 阅读 · 0 评论 -
Django models.py 加外键时候报错ValueError: The database backend does not accept 0 as a value for AutoField.
这错误主要原因是修改了原来的外键,改变了表名(Class xxx(modles.Model):),错误原因是迁移文件冲突:修改方法:migrations文件下面除了__int__.py全部删除掉,重新迁移命令(python mange.py migratons 和migrate )由于我的数据库是刚搭建状态,没重要数据,这么修改比较快感谢提供帮助:https://blog.youkuaiyun.com/weixin_42322444/article/details/105498775...原创 2021-11-17 21:23:07 · 1499 阅读 · 2 评论 -
使用scrapy爬数据时候 IndexError: list index out of range
错误原因:xpath解析数据成列表list, 取列表list[0]时列表其实是空的,list index out of range错误代码如下:content_list = response.xpath('//html/body/div[1]/div[4]/div[4]/div[2]/div/div') for cont in content_list: re_name = cont.xpath('./div/div[2]/div[1]/span/a/text()原创 2020-08-25 11:09:01 · 953 阅读 · 0 评论 -
scrapy管道存储时报错:AttributeError: ‘NoneType‘ object has no attribute ‘write‘
练习scrapy框架的管道存储时报错,报错代码:class JuliveproPipeline: fp = None def start_spider(self,spider): print('_______start crawl……') self.fp = open('./julive.txt','w',encoding='utf-8') def process_item(self, item, spider): name = i原创 2020-08-23 22:36:46 · 5096 阅读 · 5 评论 -
webdriver.Firefox 和 webdrever.firefox
进度selenium第一节课,讲了一下浏览器驱动下载。课程老师用的是Chrome,自己用的是Firefox于是遇到了一个问题。在浏览器实例化的时候报错代码:from selenium import webdriver#实例化浏览器expro = webdriver.firefox(executable_path='./geckodriver.exe')报错如下:Traceback (most recent call last): File “C:/Pycharm/PyCharmCo原创 2020-08-11 18:07:58 · 483 阅读 · 0 评论