Label: 1, Position: (0, 0), Size: 2212 x 1578 Label: 2, Position: (1596, 1281), Size: 28 x 17 Label: 3, Position: (1578, 1286), Size: 25 x 18 Label: 4, Position: (1619, 1288), Size: 42 x 43 Label: 5, Position: (1534, 1289), Size: 44 x 11 Label: 6, Position: (1558, 1289), Size: 23 x 20 Label: 7, Position: (1593, 1295), Size: 34 x 21 Label: 8, Position: (1538, 1296), Size: 23 x 18 Label: 9, Position: (1520, 1300), Size: 21 x 19 Label: 10, Position: (1569, 1303), Size: 27 x 20
时间: 2024-04-02 10:37:12 浏览: 19
(0, 0, 2212, 1578)
(1596, 1281, 28, 17)
(1578, 1286, 25, 18)
(1619, 1288, 42, 43)
(1534, 1289, 44, 11)
(1558, 1289, 23, 20)
(1593, 1295, 34, 21)
(1538, 1296, 23, 18)
(1520, 1300, 21, 19)
(1569, 1303, 27, 20)
相关问题
Label: 1, Position: (0, 0), Size: 2212 x 1578 Label: 2, Position: (1596, 1281), Size: 28 x 17 Label: 3, Position: (1578, 1286), Size: 25 x 18 Label: 4, Position: (1619, 1288), Size: 42 x 43 Label: 5, Position: (1534, 1289), Size: 44 x 11给每一行两边加上分号
你可以使用字符串操作和循环来实现这个转换。下面是一个示例代码:
```python
string = "Label: 1, Position: (0, 0), Size: 2212 x 1578\nLabel: 2, Position: (1596, 1281), Size: 28 x 17\nLabel: 3, Position: (1578, 1286), Size: 25 x 18\nLabel: 4, Position: (1619, 1288), Size: 42 x 43\nLabel: 5, Position: (1534, 1289), Size: 44 x 11"
lines = string.split("\n")
new_lines = []
for line in lines:
new_line = f"; {line} ;"
new_lines.append(new_line)
result = "\n".join(new_lines)
print(result)
```
这个代码会输出以下结果:
```
; Label: 1, Position: (0, 0), Size: 2212 x 1578 ;
; Label: 2, Position: (1596, 1281), Size: 28 x 17 ;
; Label: 3, Position: (1578, 1286), Size: 25 x 18 ;
; Label: 4, Position: (1619, 1288), Size: 42 x 43 ;
; Label: 5, Position: (1534, 1289), Size: 44 x 11 ;
```
注意,这个代码假设输入的字符串格式都相同。如果输入的字符串格式不同,可能需要对代码进行相应的修改。
Label: 2, Position: (1596, 1281), Size: 28 x 17 Label: 3, Position: (1578, 1286), Size: 25 x 18改为(1596,1281,28,17)的形式
这里有两个字符串需要转换,你可以使用循环来处理它们。下面是一个示例代码:
```python
strings = ["Label: 2, Position: (1596, 1281), Size: 28 x 17", "Label: 3, Position: (1578, 1286), Size: 25 x 18"]
new_strings = []
for string in strings:
label, position, size = string.split(", ")
x, y = position.strip("()").split(", ")
w, h = size.split(" x ")
new_string = f"{x}, {y}, {w}, {h}"
new_strings.append(f"{label}, Position: ({new_string})")
result = " ".join(new_strings)
print(result)
```
这个代码会输出以下结果:
```
Label: 2, Position: (1596, 1281, 28, 17) Label: 3, Position: (1578, 1286, 25, 18)
```
注意,这个代码假设输入的字符串格式都相同。如果输入的字符串格式不同,可能需要对代码进行相应的修改。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![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)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)