UA3P1_X = ['0.7919', '-0.5143', '-0.3238', '0.8401', '0.7636', '0.5000', '-0.8144', '-1.6401', '3.2100', '0.5284', '-0.4426', '0.7927']按三个三个分成四个list
时间: 2023-08-01 12:13:07 浏览: 42
可以使用切片操作,将列表UA3P1_X按照3个3个分成4个列表,代码如下:
```
UA3P1_X = ['0.7919', '-0.5143', '-0.3238', '0.8401', '0.7636', '0.5000', '-0.8144', '-1.6401', '3.2100', '0.5284', '-0.4426', '0.7927']
list1 = UA3P1_X[0:3]
list2 = UA3P1_X[3:6]
list3 = UA3P1_X[6:9]
list4 = UA3P1_X[9:12]
print(list1)
print(list2)
print(list3)
print(list4)
```
输出结果为:
```
['0.7919', '-0.5143', '-0.3238']
['0.8401', '0.7636', '0.5']
['-0.8144', '-1.6401', '3.21']
['0.5284', '-0.4426', '0.7927']
```
相关问题
PreparedStatementCallback; bad SQL grammar [select u.username,a.authority from user u,authority a,user_authority ua where ua.user_id=u.id and ua.authority_id=a.id and u.username = ?]; nested exception is java.sql.SQLSyntaxErrorException: Unknown column 'ua.user_id' in 'where clause'
这个错误信息是由于 SQL 语句语法有误,具体是在运行 `select u.username,a.authority from user u,authority a,user_authority ua where ua.user_id=u.id and ua.authority_id=a.id and u.username = ?` 时发生的。原因是 SQL 语句中的 `user_authority` 表中没有 `user_id` 这个列名,导致无法进行查询。
你需要检查一下 SQL 语句的语法,确认是否有拼写错误或者其他语法问题。同时,还需要确认数据库中的表结构是否符合 SQL 语句的要求。如果是因为表结构问题导致的错误,可以考虑修改表结构或者修改 SQL 语句来解决问题。
另外,建议使用参数化查询的方式来执行 SQL,可以避免 SQL 注入的问题。例如,在 Java 中可以使用 PreparedStatement 来执行带参数的 SQL 查询,具体可以参考以下代码示例:
```java
String sql = "select u.username,a.authority from user u,authority a,user_authority ua where ua.user_id=u.id and ua.authority_id=a.id and u.username = ?";
PreparedStatement ps = connection.prepareStatement(sql);
ps.setString(1, "user1");
ResultSet rs = ps.executeQuery();
```
import os root_path="F:/dataset/MOT/UA-DETRAC" label_flder="DETRAC-Train-Annotations-track" img_folder="DETRAC-train-data/Insight-MVT_Annotation_Train" seqs=os.listdir(root_path+"/"+label_flder) train_f=open("UA-DETRAC.train","w") count=0 for seq in seqs: print("seq:",seq) labels=os.listdir(root_path+"/"+label_flder+"/"+seq) for label in labels: img_name=label[:-4]+".jpg" save_str=root_path+"/"+img_folder+"/"+seq+'/'+img_name+"\n" print("img:",save_str) count+=1 print(count) train_f.write(save_str) train_f.close() 分析
这段代码的作用是将指定路径(root_path)下的DETRAC数据集中的训练集图片文件路径写入到UA-DETRAC.train文件中,以便后续训练模型时读取。具体来说,代码中通过os.listdir()方法获取指定路径root_path下的DETRAC-Train-Annotations-track目录中的所有子目录(即序列),并遍历每个序列中的所有标注文件。对于每个标注文件,代码使用[label[:-4]+".jpg"]将标注文件名(label)转换为对应的图片文件名(img_name),然后将图片文件路径保存到save_str变量中,并将其写入到UA-DETRAC.train文件中。最终,UA-DETRAC.train文件中保存的是DETRAC数据集中所有训练集图片的文件路径。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)