随笔分类 -  python3

文件删除
摘要:try: file_name = os.path.basename(src) file_size = os.stat(src).st_size except Exception: print("源文件不存在:", src) exit() 在ide使用中没有问题,但是封装成应用程序时就出现问题: Na 阅读全文
posted @ 2023-06-06 18:15 向前、向前 阅读(771) 评论(0) 推荐(0) 编辑
摘要:1 rows=[] 2 for rider in riders: 3 rows.append([rider.name,'\t'+rider.phonenumber,'\t'+rider.id,rider.haswallet]) 数据前面加上'\t' 阅读全文
posted @ 2023-02-22 11:32 向前、向前 阅读(95) 评论(0) 推荐(0) 编辑
摘要:方案一:requests请求成功时,设置它的编码 方案二:先解成二进制,之后再转成想要的编码方式 阅读全文
posted @ 2022-07-26 22:05 向前、向前 阅读(495) 评论(0) 推荐(0) 编辑
摘要:xpath解析表达式中出现tbody标签,是解析不出数据的比如'//*[@id="popularList"]/div/table[2]/tbody/tr/td/tbody/tr',改为'//*[@id="popularList"]/div/table[2]//tr/td//tr' 阅读全文
posted @ 2022-07-16 11:44 向前、向前 阅读(321) 评论(0) 推荐(0) 编辑
摘要:import stringprint(string.ascii_letters) # 52个英文字母大小写print(string.ascii_lowercase) # 26个小写字母print(string.ascii_uppercase) # 26个大写字母print(string.punctu 阅读全文
posted @ 2022-07-04 21:56 向前、向前 阅读(1477) 评论(0) 推荐(0) 编辑
摘要:age = 10name = "小于"print(f"{name}今年{age}岁了")print("%s今年%d岁了" % (name, age))print("{}今年{}岁了".format(name, age)) 阅读全文
posted @ 2022-07-04 20:48 向前、向前 阅读(66) 评论(0) 推荐(0) 编辑
摘要:sample 函数包括两个参数,第1个参数是列表,第2个是想要在列表中取样的数量(int)。sample 函数的返回值是一个列表。sample 函数的作用是第一个参数(列表)获取一个长度为第二个参数的随机列表。 _list = [1, 2, 3, 4, 5, 6, 7, 8, 9]print(ran 阅读全文
posted @ 2022-07-02 10:51 向前、向前 阅读(1133) 评论(0) 推荐(0) 编辑
摘要:You should consider upgrading via the 'pip install --upgrade pip' command. 提示有新版本了,可以升级pip(但是注意要把pip命令替换成pip3) pip3 install --upgrade pip 解决python “No 阅读全文
posted @ 2022-06-11 09:23 向前、向前 阅读(379) 评论(0) 推荐(0) 编辑
摘要:警告原因:之前安装插件失败或中途退出,导致插件安装出现异常导致的解决方法:找到警告信息中报错的目录,然后删掉~开头的文件夹 阅读全文
posted @ 2022-06-11 09:22 向前、向前 阅读(605) 评论(0) 推荐(0) 编辑
摘要:在使用Python时,需要使用各种各样的库,通常会使用pip直接安装,这样最为简单也最方便。但最为崩溃的地方在于有时候速度出奇的慢,因为pip默认使用的源为官方源,而官方源在国外。通常的解决方法是更换源,常见的国内源如下所示: https://pypi.tuna.tsinghua.edu.cn/si 阅读全文
posted @ 2022-06-09 19:57 向前、向前 阅读(7136) 评论(0) 推荐(0) 编辑
摘要:运行pip install 命令会从网站上下载指定的python包,默认是从 https://files.pythonhosted.org/ 网站上下载。这是个国外的网站,遇到网络情况不好的时候,可能会下载失败,我们可以通过命令,修改pip现在软件时的源。 格式: pip install 包名 -i 阅读全文
posted @ 2022-06-02 15:16 向前、向前 阅读(1180) 评论(0) 推荐(0) 编辑
摘要:from selenium import webdriverjs="window.open('{}','_blank');"#第一个网站driver=webdriver.Chrome()driver.get('http://web1.com')driver.find_element_by_id('u 阅读全文
posted @ 2022-05-21 14:12 向前、向前 阅读(1874) 评论(0) 推荐(0) 编辑
摘要:报错:selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create Chrome process.Stacktrace:Backtrace:Ordinal0 [0x00FA7AC3+25 阅读全文
posted @ 2022-05-21 14:06 向前、向前 阅读(111) 评论(0) 推荐(0) 编辑
摘要:源码:with open(os.getcwd() + "\\category.txt", encoding='utf-8') as file_read: for line in file_read.readlines(): categorys.append(json.loads(line.strip 阅读全文
posted @ 2022-05-07 10:55 向前、向前 阅读(902) 评论(0) 推荐(0) 编辑
摘要:import requests from urllib.request import urlretrieve IMAGE_URL = "http://47.104.63.70:5728/oauth2/captcha.jpg" #使用urlretrieve来下载图片 # urlretrieve(IMA 阅读全文
posted @ 2022-04-24 14:23 向前、向前 阅读(171) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示