s ='SQ432-FOGO5G', 'CR351-Yuyan' 转成 s =SQ432-FOGO5G,CR351-Yuyan
时间: 2024-01-03 15:04:28 浏览: 36
这个问题是IT类问题,答案如下:如果将元组(tuple)中的元素以特定格式输出,可以使用字符串的join方法。例如,可以使用以下代码实现将元组s中的元素转换为特定格式的字符串:
```
s = ('SQ432-FOGO5G', 'CR351-Yuyan')
s_str = ','.join(s)
print(s_str)
```
输出结果为:SQ432-FOGO5G,CR351-Yuyan
相关问题
s ={'SQ432-FOGO5G', 'CR351-Yuyan' } 转成 s ={SQ432-FOGO5G,CR351-Yuyan}
这个问题是IT类问题,答案如下:在Python中,花括号{}表示集合,集合中的元素无序且不重复。如果想要把集合中的元素以特定格式输出,可以使用字符串的format方法。例如,可以使用以下代码实现将集合s中的元素转换为特定格式的字符串:
```
s = {'SQ432-FOGO5G', 'CR351-Yuyan'}
s_str = '{{{},{}}}'.format(*s)
print(s_str)
```
输出结果为:{SQ432-FOGO5G,CR351-Yuyan}
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![crx](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![whl](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)