【问题标题】:Trying to combine this list of unicode strings试图合并这个 unicode 字符串列表
【发布时间】:2011-07-31 21:56:56
【问题描述】:

尝试合并此 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']

【问题讨论】:

  • ''.join(my_list) 有什么问题?
  • ''.join(my_list) 也适用于我,但是是的,我想正确的方法应该是 u''.join(my_list),正如 Cat Plus Plus 所说..?
  • 安德鲁遇到什么错误?

标签: python string unicode


【解决方案1】:

使用 unicode.join。

u''.join(that_list)

【讨论】:

    【解决方案2】:

    我尝试过使用 sum 和 join。没有运气。

    ?

    ''.join(the_list) 适合我。

    【讨论】:

      【解决方案3】:

      这可能是相同的帮助,但需要替换

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

      【讨论】:

        猜你喜欢
        • 2017-09-11
        • 1970-01-01
        • 2017-08-29
        • 1970-01-01
        • 1970-01-01
        • 2023-04-09
        • 1970-01-01
        • 2018-02-09
        • 1970-01-01
        相关资源
        最近更新 更多