JavaPython:String
Mine navigeerimisribale
Mine otsikasti
Java vs Python |
|
In python, string can reside in a pair of single quotes as well as a pair of double quotes. It supports multiplication: "x"*3 is "xxx".
Näide
Java | Python |
---|---|
<syntaxhighlight lang="java" line="1" >
//string String city = "New York"; String state = "California";//has to be " not ' String lines = "multi-line " + "string"; </syntaxhighlight> |
<syntaxhighlight lang="python" line="2" >
city = "New York" state = 'California'
lines = """multi-line string""" moreLines = multi-line string </syntaxhighlight> |