![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
ter_ret
这个作者很懒,什么都没留下…
展开
-
Python报错socket.gaierror: [Errno 11001] getaddrinfo failed
【代码】Python报错socket.gaierror: [Errno 11001] getaddrinfo failed。原创 2023-03-01 21:54:39 · 2966 阅读 · 1 评论 -
except Exception as e作用
except Exception as e作用原创 2022-09-26 22:59:06 · 5640 阅读 · 1 评论 -
python统计ip出现次数
# coding = utf-8import rewith open('D://1/1.txt','r',encoding='utf-8') as f: line = f.read().strip() # strip:去除首尾空格 result = re.split(r"[\s\n]", line) # \s:从左往右 \n:换行# print(result)ip_count = {}for ip in result: if ip not in ip_co原创 2021-11-17 19:35:35 · 1375 阅读 · 0 评论 -
UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xbd in position 23368: illegal multibyte sequence
注:错误# coding = utf-8import rewith open('D://1/1.txt','r') as f: line = f.read().strip() result = re.split(r"[\s\n]", line) # \s:从左往右 \n:换行 print(result)D:\python\python.exe D:/pycharm/pythonfile/2021/ip_times.pyTraceback (most recent原创 2021-11-17 19:02:29 · 389 阅读 · 0 评论 -
python->os.listdir FileNotFoundError: [WinError 3] 系统找不到指定的路径
错误:import os# 访问操作系统的模块;可以实现跨平台访问# print(os.sep)# print(os.name)dirs = "D:\\burpsuit\\burp"files = os.listdir("dirs")# print()# 返回指定目录下所有文件名和目录名print(files)解决方法:import os# 访问操作系统的模块;可以实现跨平台访问# print(os.sep)# print(os.name)# dirs = "D:\\bur原创 2021-11-14 20:38:06 · 4783 阅读 · 0 评论 -
python 进制转换
文章目录一、十六进制转换十进制二、八进制转换十进制三、二进制转换十进制一、十六进制转换十进制十六进制整数,使用0-9、a-f来表示整数,必须以0x开头x= 0xfaprint(x)D:\python\python.exe D:/pycharm/python项目/subject1.py250Process finished with exit code 0二、八进制转换十进制八进制整数,使用0-7表示整数,必须以0o开头x= 0o35print(x)D:\python\pyt原创 2021-11-02 21:31:09 · 183 阅读 · 0 评论 -
python 统计单词出现次数
# coding=utf-8# talk is cheap show me the code show me the code""" 1、用户输入英文短句 2、分割字符串 3、循环处理 4、查询"""# 用户输入英文短句msg = input("请输入你想要分割的英文字符")msg_list = msg.split() # 默认空格分割# 声明字典dict_count = {}# print(msg_list)# 3、循环处理for m in msg_list:原创 2021-10-29 11:03:46 · 5764 阅读 · 0 评论 -
python文件读写
文章目录一、文件操作1、字符2、文件写入3、追加文件4、文件读取一、文件操作资源地址,建议你们去看看,总结的挺棒的1、字符2、文件写入每次执行都会覆盖原来文件with open('D://1/1.txt',mode='w')as f: f.write("你好")#然后你们可以看到D://1/1.txt写入了你好D:\python\python.exe D:/pycharm/python项目/O28.py进程已结束,退出代码为 03、追加文件with open('D:/原创 2021-10-28 11:04:45 · 71 阅读 · 0 评论 -
python解决写入文件乱码问题
1、由于写入编码格式不同,需要转换编码with open('D://1/2.txt',mode='w',encoding='utf8)as f: f.write("你好\n")#追加内容并换行原创 2021-10-28 10:52:28 · 2448 阅读 · 0 评论 -
python 切片
文章目录一、一、list=[10,20,30,40,50,60,70,80,90]#start:1 stop:6 步长:1print(list[1:6:1])D:\python\python.exe D:/python/md5.py[20, 30, 40, 50, 60]Process finished with exit code 0原创 2021-10-26 21:24:57 · 58 阅读 · 0 评论 -
python打印直角三角形、正方形、梯形
文章目录打印行打印列一、正方形二、长方形三、梯形四、直角三角形打印行这是我自己理解的一些东西,你们先理解前面在线,后面就差不多了for i in range(1,4):#打印行 print('*')结果:D:\python\python.exe D:/python/md5.py***打印列一、正方形for i in range(1,5):#打印行 for j in range(1,5):#打印列 print("*",end="\t") pr原创 2021-10-20 10:11:57 · 4769 阅读 · 0 评论 -
python写前100奇数或偶数相加的和
文章目录一、偶数和1、使用while语句2、使用range语句二、奇数和1、使用while语句2.使用range语句一、偶数和1、使用while语句a=0y=awhile a<101: y += a a=a+2 print(y)结果D:\python\python.exe D:/python/md5.py0261220...中间略...2256235224502550Process finished with exit code 0原创 2021-10-18 11:54:37 · 1569 阅读 · 0 评论 -
python计算前一百的值
1、用while写y=0x=ywhile y<100: y = y + 1 x+=y print(x)D:\python\python.exe D:/python/md5.py13610152128364555667891105120136153171190210231253276300325351378406435465496528561595630666703741780820861原创 2021-10-18 11:14:05 · 308 阅读 · 0 评论 -
python if...else语句使用
1、使用print配合if…else如果正确就输出左边,错误就输出右边a=int(input('请输入一个整数'))b=int(input('请输入一个整数'))print(str(a)+'大于'+str(b) if a>b else str(a)+'小于'+str(b))D:\python\python.exe D:/python/md5.py请输入一个整数1请输入一个整数11大于1Process finished with exit code 02、直接使用if…e原创 2021-10-17 19:41:54 · 1353 阅读 · 0 评论 -
ERROR: XMLRPC request failed [code: -32500] RuntimeError: PyPI‘s XMLRPC API is currently disabled du
错误:http://www.dark-hamster.com/application/how-to-solve-error-message-error-xmlrpc-request-failed-code-32500-upon-executing-pip-search/解决方法:转载 2021-09-22 21:21:03 · 5943 阅读 · 0 评论 -
python基础内容和用法
文章目录一、print用法二、使用步骤1.引入库2.读入数据总结一、print用法二、使用步骤1.引入库代码如下(示例):import numpy as npimport pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsimport warningswarnings.filterwarnings('ignore')import sslssl._create_default_https_context =原创 2021-09-20 11:08:18 · 296 阅读 · 0 评论