控制输出target_id里面不重复的内容
时间: 2024-05-09 19:19:27 浏览: 7
可以使用set()函数来去除重复元素,然后再将其转换为列表输出:
```
target_id = ['A', 'B', 'C', 'A', 'D', 'B']
unique_id = list(set(target_id))
print(unique_id)
```
输出结果为:
```
['A', 'B', 'C', 'D']
```
相关问题
怎么把A文件中出现的所有target_id替换成B文件里该target_id对应的gene_id
你可以使用文本编辑器或编程语言来实现这个替换操作。如果你熟悉Python语言,可以使用以下代码:
```python
# 读取A文件和B文件
with open('A.txt', 'r') as f:
a_content = f.read()
with open('B.txt', 'r') as f:
b_content = f.read()
# 将B文件的内容转换成字典
b_dict = {}
for line in b_content.strip().split('\n'):
target_id, gene_id = line.strip().split()
b_dict[target_id] = gene_id
# 替换A文件中的target_id
for target_id, gene_id in b_dict.items():
a_content = a_content.replace(target_id, gene_id)
# 将替换后的内容写入新文件C.txt
with open('C.txt', 'w') as f:
f.write(a_content)
```
这个代码会将A文件中出现的所有target_id替换成B文件中该target_id对应的gene_id,并将结果写入新文件C.txt中。如果你不熟悉Python语言,也可以使用其他文本编辑器或编程语言来实现类似的替换操作。
target_link_libraries和link_libraries两者的内容能重复吗
可以重复,但是存在一定区别。target_link_libraries是将库链接到指定的目标上,而link_libraries是将库链接到所有目标上。当你不清楚链接到哪个目标时,可以使用link_libraries。但是如果你明确知道链接到哪个目标,最好使用target_link_libraries来指定链接的目标。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.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)
![](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)