» »

Perl vs. Python simple string test

Perl vs. Python simple string test

HotBurek ::

Dobro jutro.

Evo, malo za intermeco.

Spodnji primer:
#!/usr/bin/perl5.32.1

my $test1 = "aaa";
my $test2 = "bbb";

$test1 = $test1 . ", $test2";

print $test1 . "\n";

A ni zanimivo, da output vrne aaa, bbb, čeprav je $test2 napisan kot string. Kako sploh izpisat string "$test2"?

Če bi tak ukaz za združitev stringov napisal v Python-u:
test1 = test1 + ", test2";

Bi ven dobil: aaa, test2
root@debian:/# iptraf-ng
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window

Cleon ::

Tud python pozna interpolacijo stringov, probaj ", {test2}".

HotBurek ::

Pa res. Ok, interpolation se temu reče. Črko f je potrebno dat pred stringom. Vsaj ena od opcij je taka.
root@debian:/# iptraf-ng
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window

link_up ::

Spet vam je dolgcas ane? :) ' vs "
In and Out


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

Python

Oddelek: Programiranje
61071 (436) Randomness
»

Php pomoč

Oddelek: Programiranje
141887 (1320) Dober dan
»

Javascript in Regular Expression capture groups

Oddelek: Programiranje
5631 (581) sax15
»

[C#]Internal

Oddelek: Programiranje
5870 (779) kogledom
»

[cpp]Kako ugotoviti koliko zapisov je v arrayu?

Oddelek: Programiranje
6796 (715) technolog

Več podobnih tem