### 删除括号内的引号和逗号

x =['Jeff Bezos (chairman', ' president and CEO)', 'Werner Vogels (CTO)', '']
x ="".join(x)

x =['Jeff Bezos (chairman,president and CEO)', 'Werner Vogels (CTO)', '']

#### 2 个答案:

x = ['Jeff Bezos (chairman', ' president and CEO)', 'Werner Vogels (CTO)', '']
y = ['']
for element in x:
y[-1] += element
if element.endswith(')'):
y.append('')
print(y)
# ['Jeff Bezos (chairman president and CEO)', 'Werner Vogels (CTO)', '']

x = ['Jeff Bezos (chairman', ' president and CEO)', 'Werner Vogels (CTO)', '']
y = []
cont = False
for element in x:
if not cont:
y.append('')
y[-1] += (',' if cont else '') + element
cont = element.rfind('(') > element.rfind(')')
print(y)
# ['Jeff Bezos (chairman, president and CEO)', 'Werner Vogels (CTO)', '']

import re

x = ['Jeff Bezos (chairman', ' president and CEO)', 'Werner Vogels (CTO)', '']

m=re.search('(\(.*?\))', str(x)) #finding the pattern starting with'('ending with')'
srt=m.group(0).replace("'", "")  # replacing single quotes within brackets.
x = re.sub('(\(.*?\))', srt, str(x),1)  #replacing the updated string in list
print '\n',x

['Jeff Bezos (chairman,  president and CEO)', 'Werner Vogels (CTO)', '']