随笔分类 - python
python学习计划
摘要:爬取某网站时,某字符段报错出现如下报错:openpyxl.utils.exceptions.ILlegalCharacterError: div class="content-box">[腾讯官方专业国服加速器] <br /> 原因分析: 根据提示字段,此种报错,说明该字段中的字符串存在非法的字符,
阅读全文
摘要:运行Python报错:Fatal Python error: Py_Initialize: unable to load the file system codecModuleNotFoundError: No module named 'encodings' 处理步骤: 1.Files >>>Se
阅读全文
摘要:电脑重装Python后,重新打开Pycharm执行python,发现报错:Cannot run program "C:\Users\***\Python36\python.exe" (in directory "E:\www\python_tony\spider"): CreateProcess e
阅读全文
摘要:使用Python爬取某网站数据时候,之前一直是好好的。突然就报错:requests.exceptions.SSLError: HTTPSConnectionPool(host='api.***.cn', port = 443): Max retries exceeded with url: /acc
阅读全文
摘要:复制Openai的代码进行测试的时候,发生:Import "openai" could not be resolvedPylancereportMissingImports 以为是安装问题,检查安装,发现没有这个模块: 直接进行安装:pip install openai;报错: No matchin
阅读全文
摘要:1.概述: 1.注释:使用#,python会自动忽略#以后的语句; 2.换行:使用 \,可以使得后面的继续上前面的语句; 2.if else写法:
阅读全文
摘要:1.JupyterNoteBook的安装: pip install jupyter notebook 2.打开jupyter notebook: 2.1默认打开jupyter notebook,操作记录会保存在C盘或默认目录; 2.2 在指定目录下打开,例如J: 3.进入Python编辑环境: 4.
阅读全文
摘要:1.集合的概述: 集合相当于字典中的Key,也就是舍弃了值的字典; 使用 {} 或者 set() 来创建; 集合是无序的; 集合元素是唯一的(如果出现重复元素,会被覆盖;应用在爬虫去重); 使用in 判断元素是否存在; 集合内元素可变; 2.集合的创建: #直接创建空集,会变成字典; >>> set
阅读全文
摘要:1.元组的概述: 元组与列表类似,由任意类型的元素组成序列; 元组是不可变的(与列表不同处); 2.元组的创建及检验: >>> tuple_1 = (1,2,3,4) >>> tuple_1 (1, 2, 3, 4) >>> tuple_2 = 1,2,3 >>> tuple_2 (1, 2, 3)
阅读全文
摘要:1.字典的概述: 1.1 字典没有顺序,不能通过切片取元素; 1.2 它是通过互相不同的key值来访问元素; 1.3 字典是可变的,可以随意增加,修改或者删除其中的键值对; 2.字典的创建: >>> dic = {'a':1,'b':2} >>> dic {'a': 1, 'b': 2} >>> l
阅读全文
摘要:1.列表的创建:list或者使用 [ ]; a='dawt' list(a) ['d', 'a', 'w', 't'] a=['d', 'a', 'w', 't'] a ['d', 'a', 'w', 't'] 注意:使用list可以将其他类型的数据转换为列表; 2.列表的切片:[start, en
阅读全文
摘要:1.检验字符串长度:len(str); a = "hello python" len(a) 12 a = "hello python" len(a[::2]) ##从头取到尾,隔一个取值的长度 6 2.切割字符串:obj.split(str); a = "hello python" a.split(
阅读全文
摘要:1.Python检验字符串使用方法type(); a = "learnpythonstart!" type('a') = class 'str' 2.Python字符串转换,例如整数型 12转为字符串 2.1 整型转字符串及反转 #整型转字符串a = 12 type(a) = class 'int'
阅读全文