Why allow concatenation of string literals?

前端 未结 10 658
借酒劲吻你
借酒劲吻你 2020-11-30 14:47

I was recently bitten by a subtle bug.

char ** int2str = {
   \"zero\", // 0
   \"one\",  // 1
   \"two\"   // 2
   \"three\",// 3
   nullptr };

assert( int         


        
10条回答
  •  悲哀的现实
    2020-11-30 15:40

    From the python lexical analysis reference, section 2.4.2:

    This feature can be used to reduce the number of backslashes needed, to split long strings conveniently across long lines, or even to add comments to parts of strings

    http://docs.python.org/reference/lexical_analysis.html

提交回复
热议问题