尝试合并这列表的Unicode字符串

2 投票
3 回答
3008 浏览
提问于 2025-04-16 22:37

我想把这一串unicode字符串合并在一起。我试过用sum和join这两种方法,但都没成功。

有没有人知道我该怎么做?我只想把这些字符串合成一个大的普通文本输出。

[u'\nPanera Bread (NASDAQ: <a class="ticker" href="/stock/pnra#NASDAQ">PNRA</a>) is down 6 percent today over expectations of food inflation of 4.5% in Q3 and 5% for Q4. In addition, Panera Will Raise Menu Prices in Q4.',
 u'\nPNRA recently posted second quarter 2011 earnings of $1.18 per share. Reported earnings also outpaced the prior-year quarter earnings of 85 cents per share. ',
 u"\nBut shares were also lower ahead of the opening bell after the company reported weaker-than-expected same-store sales figures for its recent quarter late Tuesday. Its profit of $1.18 a share topped analysts' consensus call by a penny.",
 u'\nFor the twenty-six weeks ended June 28, 2011, net income was $68 million, or $2.27 per diluted share. These results compare to net income of $53 million, or $1.67 per diluted share, for the twenty-six weeks ended June 29, 2010, and represent a 36% year-over-year increase in diluted earnings per share.\n']

3 个回答

0

也许这对同样的人有帮助,不过是用替换的方法。

''.join(ur_list).replace('\n','')
1

我试过用 sum 也试过用 join,但都没成功。

?

''.join(the_list) 对我来说很好用。

9

使用 unicode.join 方法。

u''.join(that_list)

撰写回答