if 'S6.4.1' in row[0].value: TypeError: argument of type 'int' is not iterable
时间: 2023-08-14 10:36:57 浏览: 46
抱歉,这是我的失误。在上面的代码中,`row[0].value`是一个字符串,因此应该使用`in`来判断字符串是否包含目标子串。在修改后的代码中,我们应该使用`str(row[0].value)`将该单元格的值转换为字符串,然后再对其进行判断。
以下是修改后的代码:
```python
from openpyxl import load_workbook
# 打开Excel文件
wb = load_workbook(filename='C_Geely_Lotus DMS 20230606.xlsx')
# 选择Release Matrix-Lambda表格
ws = wb['Release Matrix-Lambda']
# 遍历每一行
for row in ws.iter_rows(min_row=2):
# 判断第一列是否包含目标字符串
if 'S6.4.1' in str(row[0].value):
# 输出对应的行数
print(row[0].row)
```
这样就可以正常运行了。
相关问题
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in URL [jar:file:/usr/local/tomcat/webapps/nems-hbgl/WEB-INF/lib/iplat4j-core-6.4.1.jar!/spring/framework/context/platApplicationContext-nodb-off.xml]: Cannot resolve reference to bean 'dataSource1' while setting bean property 'targetDataSources' with key [TypedStringValue: value [dataSource1], target type [null]]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource1' defined in URL [jar:file:/usr/local/tomcat/webapps/nems-hbgl/WEB-INF/lib/iplat4j-core-6.4.1.jar!/spring/framework/context/platApplicationContext-db-multidb-dbcp.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are: PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.RuntimeException: Failed to load driver class in either of HikariConfig class loader or Thread context classloader
根据你提供的信息,这是一个Spring Bean创建异常,具体原因是在设置bean属性'targetDataSources'时,无法解析对bean 'dataSource1'的引用。嵌套的异常是另一个Spring Bean创建异常,其中设置属性值时出错。在这个异常中,有一个属性批处理更新异常,其中包含一个属性访问异常。异常的原因是属性'driverClassName'抛出了异常,原因是无法加载驱动程序类。可能是由于驱动程序类没有正确地添加到类路径中或驱动程序类的名称不正确。建议检查驱动程序类是否正确添加到类路径中,并检查驱动程序类名称是否正确。同时,需要检查bean定义文件中是否正确定义了'dataSource1' bean。
删除用户目录下的.gradle文件夹后,重新构建项目,报错Download https://services.gradle.org/distributions/gradle-6.4.1-bin.zip (102.38 MB) Download https://services.gradle.org/distributions/gradle-6.4.1-bin.zip finished succeeded, took 5 m 33 s 339 ms Starting Gradle Daemon... Gradle Daemon started in 666 ms FAILURE: Build failed with an exception. * Where: Build file 'C:\Users\Fangmh\telema-biz-middle-ware\build.gradle' line: 2 * What went wrong: Plugin [id: 'io.spring.dependency-management', version: '1.0.10.RELEASE'] was not found in any of the following sources: - Gradle Core Plugins (plugin is not in 'org.gradle' namespace) - Plugin Repositories (could not resolve plugin artifact 'io.spring.dependency-management:io.spring.dependency-management.gradle.plugin:1.0.10.RELEASE') Searched in the following repositories: Gradle Central Plugin Repository * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org CONFIGURE FAILED in 6s
这个问题可能是因为Gradle依赖管理插件没有被正确加载。你可以尝试以下方法来解决这个问题:
1. 检查你的build.gradle文件中是否引入了正确的插件版本,检查是否有拼写错误。
2. 在你的build.gradle文件中添加以下代码,来指定插件的版本号:
```
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'io.spring.gradle:dependency-management-plugin:1.0.10.RELEASE'
}
}
```
3. 检查你的网络连接是否正常,Gradle可能需要从远程仓库下载插件。
4. 尝试运行`gradle clean build --refresh-dependencies`命令来清除本地Gradle缓存并重新下载依赖。
如果以上方法都没有解决问题,你可以尝试升级Gradle版本或者重新安装Gradle。