幾個程式語言對引號以及 backslash 解讀…

三個 P 開頭的語言…

PHP

#!/usr/bin/env php
<?php
 
echo "\\\"\'", "\n";
echo '\\\"\'', "\n";

Perl

#!/usr/bin/env perl
 
use 5.010;
use strict;
use warnings;
 
INIT {
    $a = "\\\"\'";
    $b = '\\\"\'';
 
    say $a;
    say $b;
}
 
__END__

Python

#!/usr/bin/env python
 
print "\\\"\'"
print '\\\"\''

結果是:

$ ./quote.php
\"\'
\\"'

$ ./quote.pl
\"'
\\"'

$ ./quote.py
\"'
\"'

這…

Related Posts:

This entry was posted in Computer, Murmuring, Programming and tagged , , , , . Bookmark the permalink.
  • MowdChen

    Python蠻合理的啊,其他兩個就…