1
我有一个['this', 'that']
形式的字符串数组。从字符串构建Python字符串
我需要的,说结束的字符串:
('this', 'that')
我知道我能得到逗号与。加入(),我怎样才能解决每个项目的报价中最优雅办法?
我有一个['this', 'that']
形式的字符串数组。从字符串构建Python字符串
我需要的,说结束的字符串:
('this', 'that')
我知道我能得到逗号与。加入(),我怎样才能解决每个项目的报价中最优雅办法?
Like vaultah表示使用repr()
它用于计算对象的字符串表示形式。
例如,
如果array = ['this', 'that', 'is', 'the', 'input']
然后array = repr(tuple(array))
将导致:('this', 'that', 'is', 'the', 'input')
只需使用'repr':'再版(数组(数组))' – vaultah
,使该正确的答案,但方括号;有没有简单的把它们换成圆形的? (这是一个SQL查询) – cjm2671
奇怪的是,'repr(tuple(array))'给了我很好的圆括号。 – Kevin