问题
Jython 2.5.2 (Release_2_5_2:7206, Mar 2 2011, 23:12:06)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_20
Type "help", "copyright", "credits" or "license" for more information.
>>> print 3
3
>>> print "3"
...
I tried version Jython 2.2.1, it was ok, but the problem remains in version Jython 2.7b1:
Jython 2.7b1 (default:ac42d59644e9, Feb 9 2013, 15:24:52)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_39
Type "help", "copyright", "credits" or "license" for more information.
>>> print 'ab'
...
回答1:
I tried this and my version works good:
Jython 2.5.3 (2.5:c56500f08d34+, Aug 13 2012, 14:48:36)
[Java HotSpot(TM) Client VM (Oracle Corporation)] on java1.7.0_09
Type "help", "copyright", "credits" or "license" for more information.
>>> print 3
3
>>> print "3"
3
I use more recent versions of both Jython and Java, but I think this is not problem in your case. Try to save those print
statements in print_test.py
file and execute it via jython print_test.py
and with CPython python print_test.py
. Show us results.
回答2:
same problem here:
Jython 2.5.2 (Release_2_5_2:7206, Mar 2 2011, 23:12:06)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.7.0_02
Type "help", "copyright", "credits" or "license" for more information.
>>> print 'hi'
...
Looks like just a bug for 2.5.2
回答3:
Perhaps this is specific to the OS or machine environment, as it behaves for me on windows in 2.7.0 and have seen it behave in previous versions.
Jython 2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.7.0_51
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.platform()
'Java-1.7.0_51-Java_HotSpot-TM-_64-Bit_Server_VM,_24.51-b03,_Oracle_Corporation-on-Windows_7-6.1-amd64'
>>> print 3
3
>>> print '3'
3
>>> print "3"
3
What is the underlying OS and how are you invoking the console? Do you have the problem with constructs other than print or when not referencing a quoted string?
来源:https://stackoverflow.com/questions/13794278/jython-2-5-cant-print-string