热门分割两行或多行的字符串文字? [英] Hot to split string literals that will across two or more lines ?

查看:71
本文介绍了热门分割两行或多行的字符串文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我需要打印一个很长的刺,这是两个长的所以它必须扩展两个

行。

我知道我们可以使用反斜杠(\)将两行明确地连接成一个

逻辑行,

但这对字符串文字不起作用: (


我的代码:

-------------------------- -------------------------------------------------- -

如果......:

print"字符串whcih非常非常looooooooooooooooooooooooooooooooooo \

oooooooooooooooooooong。"

----------------------------------------------- ------------------------------


如果我不打破如果我打破

行,那会非常难看......但是如何?


提前致谢!


xiaojf

解决方案



肖建峰写道:< blockquote class =post_quotes>

我需要打印很长时间sting,这是两个很长的所以它必须扩展两行。
我知道我们可以使用反斜杠(\)将两行明确地连接成一条
逻辑行,
但这对字符串文字不起作用:(

我的代码:
----------------------- -------------------------------------------------- ----
如果......:打印一个字符串whcih非常非常looooooooooooooooooooooooooooooooooo。\ n -------------------------------------------------- -----------------

如果我不打破界限,如果我打破
线就会非常难看,....但是如何?

提前致谢! python中的
有三个引用的字符串:

strVar ="""这个开头

这是结尾""
xiaojf






肖建峰写道:



我需要打印一个很长的刺,这是两个长的所以它必须扩展两行。
我知道我们可以使用反斜杠(\)来明确地连接两个将这些行划分为
逻辑行,
但这对字符串文字不起作用:(

我的代码:
--------- -------------------------------------------------- ------------------
如果......:
打印一个字符串whcih非常非常looooooooooooooooooooooooooooooooooo或者ooooooooooooooooooooo。
---------------------------------------------- -------------------------------

如果我不打破这条线,那就是如果我打破
线,会非常难看......但是如何?

谢谢提前!
在python中有三个引用的字符串:

strVar ="""这个开头

这是结束"" ;"
xiaojf




>打印一个字符串whcih非常非常looooooooooooooooooooooooooooooooooo \

oooooooooooooooooooong。




print"一个非常loooooo的字符串" \

+" ooooong。"


- Lars


-

Lars Kellogg-Stedman< 82 ************* @ jetable.net>

此电子邮件地址将于2005-11-23到期。


Hi,

I need to print a long sting, which is two long so it must expand two
lines.
I know that we can use backslash(\) to explicitly join two lines into a
logical line,
but this doesn''t work for string literals :(

my code:
-----------------------------------------------------------------------------
if sth.:
print "a string whcih is very very looooooooooooooooooooooooooooooooooo\
oooooooooooooooooooong."
-----------------------------------------------------------------------------

If I don''t break the line, it will be very ugly, if I break the
line,....but how ?

Thanks in advance!

xiaojf


解决方案


Xiao Jianfeng wrote:

Hi,

I need to print a long sting, which is two long so it must expand two
lines.
I know that we can use backslash(\) to explicitly join two lines into a
logical line,
but this doesn''t work for string literals :(

my code:
-----------------------------------------------------------------------------
if sth.:
print "a string whcih is very very looooooooooooooooooooooooooooooooooo\
oooooooooooooooooooong."
-----------------------------------------------------------------------------

If I don''t break the line, it will be very ugly, if I break the
line,....but how ?

Thanks in advance! in python there are triple quoted strings:
strVar = """this the beginning
and this is the end """
xiaojf





Xiao Jianfeng wrote:

Hi,

I need to print a long sting, which is two long so it must expand two
lines.
I know that we can use backslash(\) to explicitly join two lines into a
logical line,
but this doesn''t work for string literals :(

my code:
-----------------------------------------------------------------------------
if sth.:
print "a string whcih is very very looooooooooooooooooooooooooooooooooo\
oooooooooooooooooooong."
-----------------------------------------------------------------------------

If I don''t break the line, it will be very ugly, if I break the
line,....but how ?

Thanks in advance! in python there are triple quoted strings:
strVar = """this the beginning
and this is the end """
xiaojf




> print "a string whcih is very very looooooooooooooooooooooooooooooooooo\

oooooooooooooooooooong."



print "a string which is very loooooo" \
+ "ooooong."

-- Lars

--
Lars Kellogg-Stedman <82*************@jetable.net>
This email address will expire on 2005-11-23.


这篇关于热门分割两行或多行的字符串文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆