Re: [Jython-users] Concating string and number..
by Jingzhao Ou other posts by this author
Oct 14 2003 9:19AM messages near this date
Re: [Jython-users] Concating string and number..
|
Re: [Jython-users] Concating string and number..
Why not use str()?
> >> import java
> >> a = java.lang.Integer(34)
> >> a
34
> >> a.__class__
<jclass java.lang.Integer at 31965176>
> >> 'n' + str(a)
'n34'
Best regards,
Jingzhao
--- Jim Adrig <jim@[...].com> wrote:
> Numeric -> String conversion is done with the BACK-quote character
> `<num>`. So to concatenate:
>
> s = 'test'
> n = 123
> c = s + `n`
>
> This one got me too when I started using Jython.
>
> Of course if you REALLY WANT to use Java, you could; for Integers:
>
> from java.lang import Integer
> c = s + Integer(a).toString()
>
> Although if it might not be an Integer it would be harder.
>
> Anyway, `` handles PyInteger and PyFloat.
>
> Have fun !
>
> - Jim
>
> On Monday, October 13, 2003, at 10:40 PM, Vijay Mulimani wrote:
>
> > Hi All,
> > I have just started using Jython and do not have have a very deep
> > knowledge about it. I am facing problem in concatenating a string
> > value with a numeric value.
> > Example- The string is stored in a variable, and there is another
> > variable which has a numeric value, I want to concatenate the string
> > and numeric value.
> > I tried but it's not as same as in Java.
> > Some might find this Q as a very silly and basic !!! But help is
> > appreciated.
> >
> > Thanks in advance.
> >
> > Vijay
>
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
Jython-users mailing list
Jython-users@[...].net
https://lists.sourceforge.net/lists/listinfo/jython-users
Thread:
Vijay Mulimani
Jim Adrig
Jingzhao Ou
patrickchamberlain
patrickchamberlain
|