0 Python and Perl differences

Source: Internet
Author: User
help (dit.keys) --- Use help to view the description of the keys function in the dictionary type

About print
Python --- no need to add \ n after a string
per --- will not wrap automatically, you need to add \ n

About executing SQL statements.
python is the same as perl
When using variables to receive, it is a two-dimensional array,
Each query result is a one-dimensional array.
Each field is an element in a one-dimensional array
## Note:
If Python executes SQL and returns a row of data, it is a one-dimensional array, and if it returns multiple rows of data, it is a two-dimensional array.


The difference between python and perl is:
Python uses fetchall () function to fetch all rows at once,
Perl reads a record every time it is read


Regarding indentation:
Python pays attention to indentation, sometimes it looks aligned, but it still reports indentation errors.
In this case, there are TAB indentation and space indentation.

So, generally use the same indentation in the same script (either all TAB or all spaces)

About {} []
Perl arrays and hashes are generated using () qw,
---- It's just that the array is indexed by [] and the hash is indexed by {}
Python () means tuple, [] means array, {} means dictionary, that is, hash

About functions:
Perl uses {} the same as C, but the formal parameters are obtained using the special variable @_. Key word sub ## PERL uses a lot of special variables
Python uses indentation to distinguish function blocks, the key word def


Questions about python version:
In the old version 2.0, print ("Chinese is in it") will be garbled when printed on the screen, and it is normal to print to a file
## In the old version 2.0, if you print Chinese to the screen, it is better not to add () brackets. Printing to a file doesn't matter

 

0Difference between python and perl
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.