幾個程式語言對引號以及 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
\"'
\"'

這...

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

One Response to 幾個程式語言對引號以及 backslash 解讀...

  1. MowdChen says:

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

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>