If you've studied any one programming language, because the basic grammar of each language to do basic fact of the matter is the same, only that way or some place a little different, so when will it learn Python other you have mastered the contrast with the programming language to learn, so learn it faster, the effect is better. The following will compare Python basic grammar and basic grammar of JavaScript:
|
JavaScript |
Python |
Logic |
||
Logical NOT |
! |
not |
Logically true |
true |
True |
Logical false |
false |
False |
Conditional |
||
|
if (condition) { ... } Else if (condition) { ... }else{ ... } |
if conditions: ... elif condition: ... else: ... |
The for loop (something only the collection of circulation) |
||
|
for x in the collection: ... |
for(var i =0; i<x;i++){ ... } |
while (any object can be cyclic) |
||
|
i = 0 while i < 6: |
|
Operators |
||
|
@: Take divisible - down to the nearest integer divisor close |
|
|
//=: |
|
++: increment |
no |
Have |
--:cut back |
no |
Have |
+= |
Have |
Have |
-= |
Have |
Have |
String escaping |
||
\\ |
Backslash |
with |
\’ |
apostrophe |
with |
\” |
Double quotes |
with |
\a |
Bell |
with |
\b |
Backspace |
with |
\f |
Form filling |
with |
\n |
Newline |
with |
\r |
Enter |
with |
\t |
Tabs |
with |
\ v |
Vertical tab |
with |
Other Python syntax:
String:
String output variables:
Do the current line with newline characters:
''' '''/""" """作用:
1, multi-line comment;
2, exactly between the output content;
"\"作用:
1、转义特定字符,如:", ', \;
2、表示无法录入的字符,如:\n,\t,\r;
3、连接不同行的文本;
函数:
*args里的*是什么意思?
它的功能是告诉Python把函数的所有参数都接收进来,然后放到名叫args的列表中去。和一直在在用的argv差不多,只不过前者是用在函数上。