<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0">
<channel>
<title>深山工作室 https://www.qwbm.com【python】</title>
<link>https://www.qwbm.com/news.asp?id=46</link>
<description>python https://www.qwbm.com</description>
<category>python</category>
<language>zh-cn</language>
<docs>https://www.qwbm.com/rss.asp</docs>
<generator>https://www.qwbm.com</generator>
<webMaster>565449214@qq.com</webMaster>
<managingEditor>565449214@qq.com</managingEditor>
<pubDate>2007-11-21 下午 23:11:35</pubDate>
<lastBuildDate>2026/5/3 11:56:00</lastBuildDate>
<ttl>20</ttl> 
<copyright>Copyright 2026 深山工作室 https://www.qwbm.com</copyright>
<item>
<guid>11349</guid>
<title>Android移动端自动化测试：使用UIAutomatorViewer与Selenium定位元素</title>
<link>https://www.qwbm.com/new.asp?id=11349</link>
<description><![CDATA[APP移动端自动化测试】第三节.UIAutomatorViewer元素定位API操作

（1）应用场景
定位元素的时候必须根据元素的相关特征来进行定位，而UIAutomatorViewer就是用来获取元素特征的。
（2）简介
UlAutomatorViewer用来扫描和分析Android应用程序的UI控件的工具。
（3）使用步骤
1．进入SDK目录下的目录
mac在tools/bin目录下，打开uiautomatorviewero
windows在 tools目录下，打开uiautomatorviewer.bat
2．电脑连接真机或打开android模拟器
3．启动待测试app
4．点击uiautomatorviewer的左上角Device Screenshot (从左数第二个按钮)
5．点击希望查看的控件
6．查看右下角Node Detail相关信息
（4）示例
查看《设置》应用程序右上角"放大镜”按钮的"resource-id".
&nbsp;&nbsp;&nbsp; 实现步骤：
&nbsp;&nbsp;&nbsp; 1.打开uiautomato]]></description>
<author></author>
<source>https://www.qwbm.com/new.asp?id=11349</source>
<category>python</category>
<pubDate>2024/9/18 14:33:40</pubDate>
</item>
<item>
<guid>7349</guid>
<title>python通过代码修改pip下载源让下载库飞起</title>
<link>https://www.qwbm.com/new.asp?id=7349</link>
<description><![CDATA[临时解决
python.exe -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple numpy

修改配置永久有效
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple]]></description>
<author></author>
<source>https://www.qwbm.com/new.asp?id=7349</source>
<category>python</category>
<pubDate>2024/3/6 15:57:10</pubDate>
</item>
<item>
<guid>6349</guid>
<title>python里面requests.post返回的res.text还有其它的吗</title>
<link>https://www.qwbm.com/new.asp?id=6349</link>
<description><![CDATA[在 Python 的 requests 库中,使用 requests.post 发送 POST 请求后,返回的响应对象 res 包含很多属性和方法,主要有:
- res.status_code: 响应的 HTTP 状态码
- res.text: 响应内容的字符串形式,res.content 的 decode 版本
- res.content: 响应内容的二进制形式
- res.headers: 响应头部信息
- res.cookies: 响应中的 Cookie
- res.encoding: 响应的编码
- res.json(): 将响应的 JSON 字符串解析为 Python 对象
- res.raise_for_status(): 如果状态码不是 200,会抛出异常

所以在使用 requests.post 以后,主要的数据属性有:
- res.status_code: 判断请求是否成功
- res.text: 作为字符串获取响应内容
- res.content: 作为字节获取响应内容
- res.json(): 如果响应是 JSON,解析为 Pytho]]></description>
<author></author>
<source>https://www.qwbm.com/new.asp?id=6349</source>
<category>python</category>
<pubDate>2024/1/29 15:14:32</pubDate>
</item>
<item>
<guid>4349</guid>
<title>windows7环境下安装配置jdk</title>
<link>https://www.qwbm.com/new.asp?id=4349</link>
<description><![CDATA[一、jdk下载地址：
注：这个jdk是1.8的版本
链接：https://pan.baidu.com/s/1DYG3-F0D2QDC5CjhFOwNVA 
提取码：wqnb 

二、将下载好的jdk安装包解压到e盘
如下：


三、配置java环境变量
右键我的电脑-&gt;属性-&gt;高级-&gt;环境变量-&gt;系统变量
注意：是下面的系统变量，不是上面的用户变量
新建变量名 JAVA_HOME，变量值 E:\jdk
修改变量 Path ，在最前面加上 %JAVA_HOME%\bin;
注意：“Path"是首字母大写，不要改成"PATH” bin后面要有分号;
注意：系统变量上面的用户变量里，不要有这两个，如果有应该去掉，以避免被干扰。
注意：Win10 下PATH的配置有所不同，按照下个步骤配置即可：Win10 下环境变量Path的配置



四、验证
点WIN键-&gt;运行（或者使用win+r)
输入cmd命令
输入java -version
如果出现版本信息，表明配置成功

————————————————
版权声明]]></description>
<author></author>
<source>https://www.qwbm.com/new.asp?id=4349</source>
<category>python</category>
<pubDate>2023/6/27 11:16:09</pubDate>
</item>
<item>
<guid>4348</guid>
<title>python对微信操作要用到这两个库wxpy与itchat</title>
<link>https://www.qwbm.com/new.asp?id=4348</link>
<description><![CDATA[https://github.com/youfou/wxpy
https://github.com/littlecodersh/itchat

这里对wxpy和itchat两个微信机器人开发库进行重新介绍:
# 微信机器人开发库介绍
## wxpy - 可能是最优雅的微信个人号API
wxpy是基于微信网页版的API开发的,依赖requests和Flask等模块,可以方便地用Python编写机器人。使用wxpy需要一个微信个人号和一个网页应用,并将网页应用和个人号账号关联起来使用。
### 主要功能
- 消息收发:可以接收微信消息如文本、图片等,也可以发送各种消息给联系人或群聊。
- 好友管理:可以获取全部好友列表和各好友的详细信息,也可进行好友添加/删除/备注等操作。
- 群管理:可以获取群聊列表和详细信息,发起群聊创建/加入/退出等操作。 
- 菜单管理:可以创建自定义菜单来与用户交互。 
- 多账号管理:可以同时登录和操作多个微信个人账号。
- 事件处理:可以设置各种事件的回调函数,如接收添加好友请求、群聊加入邀请等操作。

### 安装和使用
p]]></description>
<author></author>
<source>https://www.qwbm.com/new.asp?id=4348</source>
<category>python</category>
<pubDate>2023/5/2 10:13:49</pubDate>
</item>
<item>
<guid>1347</guid>
<title>8种Python字符串拼接的方法，你知道几种</title>
<link>https://www.qwbm.com/new.asp?id=1347</link>
<description><![CDATA[一、join函数
join 是 python 中字符串自带的一个方法，返回一个字符串。使用语法为：

sep.join(可迭代对象) --》 str
# sep 分隔符 可以为空


将一个包含多个字符串的可迭代对象（字符串、元组、列表），转为用分隔符sep连接的字符串。
列表
列表必须为非嵌套列表，列表元素为字符串（str）类型

list1 = ["123", "456", "789"]
print(''.join(list1)) # '123456789'
print('-'.join(list1)) # '123-456-789'

元组

#Python学习交流群：531509025
tuple1 = ('abc', 'dd', 'ff')
print(''.join(tuple1)) # 'abcddff'
print('*'.join(tuple1)) # 'abc*dd*ff'

字符串

str1 = "hello Hider"
print(''.join(str1))
print(':'.join(str1))
]]></description>
<author></author>
<source>https://www.qwbm.com/new.asp?id=1347</source>
<category>python</category>
<pubDate>2022/11/12 12:04:17</pubDate>
</item>
<item>
<guid>1346</guid>
<title>Python拼接字符串的几种方式</title>
<link>https://www.qwbm.com/new.asp?id=1346</link>
<description><![CDATA["""
1. 使用加号“+”连接字符串
用加号“+”连接两个字符串，连接后这两个字符串将连接成一个字符串。但需注意的是，
不能用“+”连接字符串和数字，需要把数字使用str()函数转换成字符串，或者直接在数字两侧加带引号，再进行连接、
"""
str11 = "hello"
str12 = "world"
str13 = str11 + str12
print(str13)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # helloworld

""" 注： 但在python中，尽量少用加号“+”连接字符串，原因如下：在python中，String对象是定长对象，一旦创建，长度就不可变化，若是使用+号连接两个字符串，则会新开辟一段长度总和长度的内存，再将两个字符串memcpy进去。如果要连接N个String对象，则要进行N-1次内存申请和拷贝。 官方推荐的是使用字符串的join方法，该方法对于连接一个list或tuple中的元素非常有效，它会先统计所有元素的长度，申请内存，然后拷贝。 """

"""
2. ]]></description>
<author></author>
<source>https://www.qwbm.com/new.asp?id=1346</source>
<category>python</category>
<pubDate>2022/11/12 11:45:13</pubDate>
</item>
<item>
<guid>1345</guid>
<title>Python pandas删除指定行/列数据的方法实例</title>
<link>https://www.qwbm.com/new.asp?id=1345</link>
<description><![CDATA[pandas是很常用的数据分析，数据处理的包。anaconda已经有这个包了，纯净版python的可以自行pip安装。

删除重复值 drop_duplicates()
df=pd.DataFrame({'state':[1,1,2,2,1,2,2],'pop':['a','b','c','d','b','c','d']})
语法：drop_duplicates(subset,keep,inplace)，其中参数 keep:{‘first’，‘last’，False}，默认’first’
first：保留第一次出现的重复项，删除第二次及之后出现的重复项。
last：保留最后一次出现的重复项，删除之前出现的重复项。
"false"：删除所有重复项。


查看有nan的行，和不含有nan的行
#1 查看含有nan的行&nbsp; &nbsp; &nbsp;df[df.isna().any(axis=1)]
#2 查看不含有nan的行&nbsp;&nbsp; df[~df.isna().any(axis=1)]&nbsp; &nbsp;#有一个符号 ~ 一定要注意这一]]></description>
<author></author>
<source>https://www.qwbm.com/new.asp?id=1345</source>
<category>python</category>
<pubDate>2022/10/28 16:42:29</pubDate>
</item>
<item>
<guid>1329</guid>
<title>让你的Pycharm和电脑pip install下载速度飞起来</title>
<link>https://www.qwbm.com/new.asp?id=1329</link>
<description><![CDATA[前言
有很多朋友刚刚学Python的时候，会来问为什么pip下载东西这么慢啊？pycharm里面下载库也是非常的慢。这其实是个常识性的问题，我们下载的慢是因为Python使用pip方法安装第三方包时，需要从 https://pypi.org/ 资源库中下载。这个网站是国外的服务器，访问自然就很慢，但是国内有很多的镜像站，所谓镜像站就是内容一样，只不过服务器在国内，访问速度自然而然就很快了。下面给大家普及一下如何修改pip的下载源以及pycharm的下载源。

电脑修改下载源
在国内，比较火的就是下面这几个下载源：

阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣 http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

我使用的是]]></description>
<author></author>
<source>https://www.qwbm.com/new.asp?id=1329</source>
<category>python</category>
<pubDate>2022/9/30 17:02:31</pubDate>
</item>
<item>
<guid>1328</guid>
<title>pywinauto技术文档</title>
<link>https://www.qwbm.com/new.asp?id=1328</link>
<description><![CDATA[全部英文技术文档pywinauto技术文档
https://pywinauto.readthedocs.io/en/latest/contents.html
常用功能文档
https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.uiawrapper.html


pywinauto常用功能的中文技术文档
https://www.kancloud.cn/gnefnuy/pywinauto_doc/1193049

pywinauto-笔记汇总
https://www.jianshu.com/p/0c1522f059fe
]]></description>
<author></author>
<source>https://www.qwbm.com/new.asp?id=1328</source>
<category>python</category>
<pubDate>2022/9/30 14:47:49</pubDate>
</item>
<item>
<guid>1327</guid>
<title>Appium元素定位方式之android_uiautomator定位</title>
<link>https://www.qwbm.com/new.asp?id=1327</link>
<description><![CDATA[1. android_uiautomator定位
&nbsp; 相当于使用 UiAutomator Api 去递归地搜索元素（Android 专属），可以说android uiautomator是终极定位方式，有的时候一些元素不能够很好的定位时，那么就需要采用android uiautomator去定位，他是一种非常强有力的定位方式，原理是通过android 自带的android uiautomator的类库去查找元素。appium对android 的uiautomator进行了封装，该方法的参数为UiSelector类定位元素的表达式：new UiSelector().属性（'属性值'），实例化一个UiSelector对象，然后通过实例接口调用。
&nbsp; AndroidUIAutomator是一个强有力的元素定位方式，它是通过Android UIAutomator类库去找元素，可以选择resourceId、text、className、description作为传入的字符串。

1.1 android_uiautomator之text文本定位语法
　　1) 使用tex]]></description>
<author></author>
<source>https://www.qwbm.com/new.asp?id=1327</source>
<category>python</category>
<pubDate>2022/9/23 17:04:58</pubDate>
</item>
<item>
<guid>1326</guid>
<title>使用uiautomatorviewer连接模拟器页面报错：Error while obtaining UI hierarchy XML file</title>
<link>https://www.qwbm.com/new.asp?id=1326</link>
<description><![CDATA[使用uiautomatorviewer连接模拟器页面报错：Error while obtaining UI hierarchy XML file: com.android.ddmlib.SyncException: Remote object doesn't exist!

解决方法1：
杀死adb服务器并重新启动它。
adb kill-server
adb start-server

命令面板执行这两条命令后再次连接即可
解决方法2：
命令面板运行：adb reconnect

运行后再次点击连接即可
]]></description>
<author></author>
<source>https://www.qwbm.com/new.asp?id=1326</source>
<category>python</category>
<pubDate>2022/9/23 17:03:38</pubDate>
</item>
<item>
<guid>1325</guid>
<title>使用uiautomatorviewer连接模拟器页面报错No Android devices were detected by adb.</title>
<link>https://www.qwbm.com/new.asp?id=1325</link>
<description><![CDATA[



原因：adb 没有连接上手机模拟器

连接夜神模拟器:解决：cmd——adb connect 127.0.0.1:62001
连接mumu模拟器:解决：cmd——adb connect 127.0.0.1:7555



打开cmd控制台，输入命令adb connect 127.0.0.1:7555即可连接模拟器。
Microsoft Windows [版本 10.0.18363.1198]
(c) 2019 Microsoft Corporation。保留所有权利。



C:\Users\ghgxj&gt;adb connect 127.0.0.1:7555
connected to 127.0.0.1:7555]]></description>
<author></author>
<source>https://www.qwbm.com/new.asp?id=1325</source>
<category>python</category>
<pubDate>2022/9/23 17:01:56</pubDate>
</item>
<item>
<guid>1324</guid>
<title>python+appium自动化测试-滑动</title>
<link>https://www.qwbm.com/new.asp?id=1324</link>
<description><![CDATA[一、scroll()方法
Appium 中webdriver提供scroll()方法来滚动页面，该方法只适用于屏幕上已经显示的两个元素，从一个元素滚动到另一个元素。若元素不存在当前屏幕或被遮挡，则无法使用该方法。

方法介绍：
scroll(self, start_el, stop_el, duration=None)：
&nbsp;&nbsp;&nbsp; 参数：
&nbsp;&nbsp;&nbsp; - start_el- 开始要滚动的元素
&nbsp;&nbsp;&nbsp; - stop_el- 要滚动到的元素
&nbsp;&nbsp;&nbsp; - 即从元素stop_el滚动至元素start_el
&nbsp;&nbsp;&nbsp; - duration 即滚动的持续时间

具体代码如下
def scroll():	
stop_el = self.driver.find_element_by_xpath("//android.widget.TextView[@text='2008']")
start_el = self.driver.find_]]></description>
<author></author>
<source>https://www.qwbm.com/new.asp?id=1324</source>
<category>python</category>
<pubDate>2022/9/23 16:05:30</pubDate>
</item>
<item>
<guid>1323</guid>
<title>Appium获取手机分辨率 & 自适应设备下滑刷新</title>
<link>https://www.qwbm.com/new.asp?id=1323</link>
<description><![CDATA[需求背景：appium做手机自动化的时候，有个很固定的需求就是竖直滑动刷新页面信息（比如：微信朋友圈、微博等），开始的时候我是固定写死的，如driver.swipe(300, 1000, 300, 300)，但是这样写的弊端也很明显，代码不够健壮，如果遇到小屏设备或者大屏设备，滑动的幅度看起来就可能过大或过小。所以我们需要根据不同分辨率的设备做自适应，使代码在各种大小的屏幕上表现的行为和体验都比较一致。

首先，我们需要获取屏幕的宽和高，Appium（python）可用get_window_size()方法获取屏幕的宽和高（可用键值索引单独获取宽或高），然后按照屏幕尺寸定义滑动幅度占屏比。因为下滑刷新是比较常用的功能，所以我封装为一个函数，方便调用，代码如下：

def scroll_down(self):
&nbsp;&nbsp;&nbsp; width = self.get_window_size()['width']
&nbsp;&nbsp;&nbsp; height = self.get_window_size()['height']
&nbsp;&nbsp;&n]]></description>
<author></author>
<source>https://www.qwbm.com/new.asp?id=1323</source>
<category>python</category>
<pubDate>2022/9/23 15:58:32</pubDate>
</item>
<item>
<guid>1322</guid>
<title>python加Appium判断滑动是否到达屏幕底部</title>
<link>https://www.qwbm.com/new.asp?id=1322</link>
<description><![CDATA[需求：在做appium自动化的过程中遇到一个问题，每次下滑都会刷新页面（比如微信朋友圈），要通过滑动获取所有页面信息，直到滑动到页面底部，但是不知道怎么判断滑动到底部从而终止滑动的循环（appium无法得知滑动成功还是失败）

appium本身没有直接判断是否滑动到页面底部的函数，但是我们可以通过一个比较笨的方法来实现滑动到页面底部的判断，思路也比较简单：判断滑动前后的页面元素是否完全一致，如果完全一致则说明滑动失败（已经滑动到了底部），如果不一致则说明滑动成功。示例代码如下：


# 获取滑动前页面元素
before_swipe = driver.page_source
# 滑动
driver.swipe(300, 1000, 300, 300) 
# 获取滑动后页面元素
after_swipe = driver.page_source
# 对比滑动前后的页面元素
# 若滑动前后页面元素完全相同，则滑动失败，已达页尾
if before_swipe == after_swipe:
&nbsp;&nbsp;&nbsp; Swiped = False
# 若]]></description>
<author></author>
<source>https://www.qwbm.com/new.asp?id=1322</source>
<category>python</category>
<pubDate>2022/9/23 15:54:47</pubDate>
</item>
<item>
<guid>1321</guid>
<title>python退出while循环break、return、continue</title>
<link>https://www.qwbm.com/new.asp?id=1321</link>
<description><![CDATA[while True:
&nbsp; &nbsp;break

1、while用于构建循环，while True是无限循环；
2、break用于退出for循环和while循环，当有多层循环时，退出break所在的循环体
3、return是用来结束函数返回数据用的，适用对象不对，所以有报错
4、continue用来结束本次循环体，从新回到continue语句所在的循环体开始下一次循环;本例中开始执行：while True:
]]></description>
<author></author>
<source>https://www.qwbm.com/new.asp?id=1321</source>
<category>python</category>
<pubDate>2022/9/23 15:49:29</pubDate>
</item>
<item>
<guid>1320</guid>
<title>Python PyInstaller安装和使用教程（详解版）</title>
<link>https://www.qwbm.com/new.asp?id=1320</link>
<description><![CDATA[安装 PyInstaller 模块
pip install pyinstaller

强烈建议使用 pip 在线安装的方式来安装 PyInstaller 模块，不要使用离线包的方式来安装，因为 PyInstaller 模块还依赖其他模块，pip 在安装 PyInstaller 模块时会先安装它的依赖模块。
官网：http://www.pyinstaller.org/



使用Pyinstaller
1、使用下载安装的方式安装的Pyinstaller打包方式
将需要打包的文件放在解压得到的Pyinstaller文件夹中，打开cmd窗口，把路径切换到当前路径打开命令提示行，输入以下内容（最后的是文件名）：

python pyinstaller.py -F myfile.py
2、使用pip方式安装的Pyinstaller打包方式
打开cmd窗口，把路径切换到文件所在路径(文件随便放在哪里都行)打开命令提示行，输入以下内容（最后的是文件名）：

pyinstaller -F myfile.py
3、输入参数的含义
-F 表示生成单个可执行文件
-w ]]></description>
<author></author>
<source>https://www.qwbm.com/new.asp?id=1320</source>
<category>python</category>
<pubDate>2022/9/16 14:10:30</pubDate>
</item>
<item>
<guid>1319</guid>
<title>python自动控制鼠标操作pymouse</title>
<link>https://www.qwbm.com/new.asp?id=1319</link>
<description><![CDATA[安装PyMouse库
1.使用pip可以直接下载pymouse
&nbsp;pip install pymouse
&nbsp;或者
&nbsp;pip install -i https://mirrors.aliyun.com/pypi/simple/ --upgrade pymouse

2.第二步：需要安装 PyUserinput、pyHook
若不安装PyUserinput，导入包pyMouse则报错： ModuleNotFoundError: No module named ‘windows’


找到pymouse的安装路径，如果不知道在哪里可以用pip安装一下，如果已经安装了会自动提示安装路径，通常都是在python或者ide的Lib\site-packages里，比如我的在：

D:\Program Files (x86)\Python\Python36\Lib\site-packages\pymouse

__init__.py
进入pymouse的安装路径打开__init__.py文件；
把92行的92行的from windows i]]></description>
<author></author>
<source>https://www.qwbm.com/new.asp?id=1319</source>
<category>python</category>
<pubDate>2022/9/16 9:25:02</pubDate>
</item>
<item>
<guid>1318</guid>
<title>NameError: name ‘xxx‘ is not defined问题总结</title>
<link>https://www.qwbm.com/new.asp?id=1318</link>
<description><![CDATA[


最近在使用python写实验遇到这个问题：
NameError: name ‘xxx’ is not defined
在学习python或者在使用python的过程中这个问题大家肯定都遇到过，在这里我就这个问题总结以下几种情况：

错误NameError: name ‘xxx’ is not defined总结

情况一：要加双引号（" "）或者（’ '）而没加
情况二：字符缩进格式的问题
情况三：if __name__=='__main__' : 没有和class类进行对齐
情况四：NameError: name ‘file’ is not defined
情况五：NameError: name ‘模块’ is not defined
情况六：NameError: name ‘reload’ is not defined
情况七：全局变量的问题
情况八：两个.py文件的函数或类调用问题(一个.py文件要调用另一个.py文件中的函数或者类时，需要添加该代码文件所在路径，否则会报“NameError: name ‘XXX’ is not define]]></description>
<author></author>
<source>https://www.qwbm.com/new.asp?id=1318</source>
<category>python</category>
<pubDate>2022/9/15 18:09:07</pubDate>
</item>
<item>
<guid>1317</guid>
<title>总结一下with open()和open()的区别与使用方法</title>
<link>https://www.qwbm.com/new.asp?id=1317</link>
<description><![CDATA[使用例子：
with open('app.txt', 'w', encoding="utf-8") as file:
&nbsp;&nbsp;&nbsp; file.write(ls_cont)


1.用途：是python用来打开本地文件的，他会在使用完毕后，自动关闭文件，无需手动书写close()

2.用法：
with open (file = "你要打开的路径名（或保存内容的地址）",mode = "r/w/a",encoding = "utf-8") as f1:
&nbsp; &nbsp; &nbsp; &nbsp; data = f1.read/write()
&nbsp; &nbsp; &nbsp; &nbsp; print(data)

3.关于mde的三种模式：
&nbsp;&nbsp;&nbsp; r：只读&nbsp; 用read()
&nbsp;&nbsp;&nbsp; w：只写 用write() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; //会清除之前写的内容
&nbsp;&nbsp;&nb]]></description>
<author></author>
<source>https://www.qwbm.com/new.asp?id=1317</source>
<category>python</category>
<pubDate>2022/9/14 15:23:30</pubDate>
</item>
<item>
<guid>1316</guid>
<title>python中 f 用法</title>
<link>https://www.qwbm.com/new.asp?id=1316</link>
<description><![CDATA[python中f‘{}‘用法
python的字符串前面加f表示格式化字符串，加f后可以在字符串里面使用用花括号括起来的变量和表达式，如果字符串里面没有表达式，那么前面加不加f输出应该都一样。

Python3.6新增了一种f-字符串格式化
格式化的字符串文字前缀为’f’和接受的格式字符串相似str.format()。它们包含由花括号包围的替换区域。替换字段是表达式，在运行时进行评估，然后使用format()协议进行格式化。
formatted string literals, 以 f 开头，包含的{}表达式在程序运行时会被表达式的值代替。

如： 

f'名称: {i["value"]}'

python3.6增加的方法，字符串定义以f开头，可以使用{}包裹变量，方便字符串的定义。
print(f'features:,{features.shape},\n,labels.shape:,{labels.shape}')
print(f'features:,{features.shape} \n labels.shape:,{labels.shape}')#不加逗]]></description>
<author></author>
<source>https://www.qwbm.com/new.asp?id=1316</source>
<category>python</category>
<pubDate>2022/9/14 14:57:56</pubDate>
</item>
<item>
<guid>1315</guid>
<title>python错误yntaxError: Non-UTF-8 code starting with '\xd3' in file 文件.py but no encoding declared</title>
<link>https://www.qwbm.com/new.asp?id=1315</link>
<description><![CDATA[python运行程序提示错误

"D:\Program Files (x86)\Python\Python36\python.exe" D:/python_projects/写的案例/模仿客服机器人.py
&nbsp; File "D:/python_projects/写的案例/模仿客服机器人.py", line 19
SyntaxError: Non-UTF-8 code starting with '\xd3' in file D:/python_projects/写的案例/模仿客服机器人.py on line 19, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

这是python解码出错



解决办法：在代码首行添加： #coding=gbk


---------------------------- 这是侵害线 ------------------------------------


其它遇到的问题：
SyntaxError]]></description>
<author></author>
<source>https://www.qwbm.com/new.asp?id=1315</source>
<category>python</category>
<pubDate>2022/9/14 14:35:23</pubDate>
</item>
</channel>
</rss>
