Py学习  »  Python

如何使用python从元组中移除特定字符

wilberox • 4 年前 • 690 次点击  

我有一个元组:

tuple = ('one', ('two', 'three'))

我想打印删除 ' 从这个元组中,我可以把它打印成 (one, (two, three)) .

我试过了

tuple = str(tuple)
print tuple.strip(')

但我有个错误:

    print tuple.strip(')
                       ^
SyntaxError: EOL while scanning string literal

如何将元组转换为所需的字符串?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/50989
 
690 次点击  
文章 [ 2 ]  |  最新文章 4 年前