Hi all,
I have some strings, let it be string1, string2, string3.
So how could String=
"""
string1
string2
string3
"""
be obtained?
Thank you in advance, D. 8 2004
dmitrey wrote:
Hi all,
I have some strings, let it be string1, string2, string3.
So how could String=
"""
string1
string2
string3
"""
be obtained?
Thank you in advance, D.
If you just want the to add newlines between the strings then you can do
the following:
String = '\\n'.join([string1,string2,string3])
-Farshid
Thanks all, I have solved the problem:
a="""
%s
%s
%s
""" % ('asdf', 'asdf2', 'asdf3')
print a
D.
On Tue, Nov 20, 2007 at 11:40:59AM -0800, Farshid Lashkari wrote regarding Re: Python strings question (vertical stack):
>
dmitrey wrote:
Hi all,
I have some strings, let it be string1, string2, string3.
So how could String=
"""
string1
string2
string3
"""
be obtained?
Thank you in advance, D.
If you just want the to add newlines between the strings then you can do
the following:
String = '\\n'.join([string1,string2,string3])
-Farshid
-- http://mail.python.org/mailman/listinfo/python-list
I think you mean '\n'.join([string1,string2,string3])
You actually do want the \ to do its thing in this case.
Cheers,
Cliff
J. Clifford Dyer wrote:
I think you mean '\n'.join([string1,string2,string3])
You actually do want the \ to do its thing in this case.
Yeah, my brain must still be asleep. Thanks for waking it up :)
On Nov 21, 7:15 am, Farshid Lashkari <n...@spam.comwrote:
J. Clifford Dyer wrote:
I think you mean '\n'.join([string1,string2,string3])
You actually do want the \ to do its thing in this case.
Yeah, my brain must still be asleep. Thanks for waking it up :)
You're not alone :-)
>>a = """
.... x
.... y
.... z
.... """
>>a
'\nx\ny\nz\n'
>>'\n'.join(['x', 'y', 'z'])
'x\ny\nz'
>>>
James Matthews top-posted:
I would say to split it by the newline!
Split what by which newline? The OP appeared to be wanting some kind of
UNsplit ...
>
On Nov 20, 2007 10:59 PM, John Machin <sj******@lexicon.net
<mailto:sj******@lexicon.net>wrote:
On Nov 21, 7:15 am, Farshid Lashkari <n...@spam.com
<mailto:n...@spam.com>wrote:
J. Clifford Dyer wrote:
I think you mean '\n'.join([string1,string2,string3])
>
You actually do want the \ to do its thing in this case.
>
Yeah, my brain must still be asleep. Thanks for waking it up :)
You're not alone :-)
Early indications of a pandemic??
>
>>a = """
... x
... y
... z
... """
>>a
'\nx\ny\nz\n'
>>'\n'.join(['x', 'y', 'z'])
'x\ny\nz'
>>>
dmitrey schrieb:
Thanks all, I have solved the problem:
a="""
%s
%s
%s
""" % ('asdf', 'asdf2', 'asdf3')
print a
This is more expensive and not as flexible as the join method. At least
for growing string-lengths and number of arguments.
Diez
On Tue, 2007-11-20 at 13:59 -0800, John Machin wrote:
On Nov 21, 7:15 am, Farshid Lashkari <n...@spam.comwrote:
J. Clifford Dyer wrote:
I think you mean '\n'.join([string1,string2,string3])
You actually do want the \ to do its thing in this case.
Yeah, my brain must still be asleep. Thanks for waking it up :)
You're not alone :-)
>a = """
... x
... y
... z
... """
>a
'\nx\ny\nz\n'
>'\n'.join(['x', 'y', 'z'])
'x\ny\nz'
>>
It's true: my solution did not match the exact specification given by
the OP's code, but 1) I was responding to Farshid Lashkari's slip and 2)
It does what the OP was ultimately asking for--it stacks the results
vertically. My brain was not asleep, I was just not interested in the
other, largely irrelevant part of the OP's question. If he wants a new
line at the beginning and end, I'm sure he can figure out how to do it.
I don't need to jump through those hoops for him.
Cheers,
Cliff This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: mike420 |
last post by:
I think everyone who used Python will agree that its syntax is
the best thing going for it. It is very readable and easy
for everyone to learn. But, Python does not a have very good
macro...
|
by: Kurt B. Kaiser |
last post by:
Patch / Bug Summary
___________________
Patches : 241 open ( -6) / 2622 closed (+26) / 2863 total (+20)
Bugs : 764 open ( +6) / 4453 closed (+38) / 5217 total (+44)
RFE : 150 open...
|
by: ajikoe |
last post by:
Hi,
I tried to follow the example in swig homepage.
I found error which I don't understand.
I use bcc32, I already include directory where my python.h exist in
bcc32.cfg.
/* File : example.c...
|
by: Mark Tarver |
last post by:
How do you compare Python to Lisp? What specific advantages do you
think that one has over the other?
Note I'm not a Python person and I have no axes to grind here. This is
just a question for...
|
by: WaterWalk |
last post by:
I've just read an article "Building Robust System" by Gerald Jay
Sussman. The article is here:
http://swiss.csail.mit.edu/classes/symbolic/spring07/readings/robust-systems.pdf
In it there is a...
|
by: Bartc |
last post by:
I'd been benchmarking my own pet language against Python for manipulation of
short strings. This tested the expression a=b+c for strings, and the Python
code looks like:
b="abc"
c="xyz"
for i...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |