本文共 1701 字,大约阅读时间需要 5 分钟。
单行注释:#
""""
或 ''''
+
加 -
减 *
乘 /
除 //
整除 %
余数 **
幂
注意:
bool
:非零为真,0为假int
:整数float
:浮点数complex
:复数(a=complex(real, imag))注意:
int()
, float()
, complex()
+
或 *
hello_world
helloWorld
(首字母小写,后续首字母大写)HelloWorld
(每个单词首字母大写)==
, !=
, >
, <
, >=
, <=
and
, or
, not
if
-elif
-else
结构import random
random.randint(a, b)
while
条件:while 条件:
break
:退出当前循环continue
:跳过当前循环print
默认换行,end=""
换行row = 1while row <= 10: col = 1 while col <= row: print("*", end="") col += 1 print("") row += 1
[]
insert()
, append()
, extend()
, del
, remove()
, pop()
, clear()
, count()
, sort()
, reverse()
for
循环( )
index()
, count()
, len()
{}
pop()
, update()
, clear()
, keys()
, values()
, items()
for
循环strip()
count()
, replace()
isdecimal()
, isdigit()
, isnumeric()
, isalpha()
, isspace()
, istitle()
split()
, join()
[索引]
lower()
, upper()
, capitalize()
, title()
ljust()
, rjust()
, center()
%
格式化format()
方法* +
int
, bool
, float
, complex
, str
, tuple
list
, dict
id()
获取引用地址hash()
方法
global
声明def
语句return
def demo(name, gender=True)
*args
, **kwargs
num_list.append(88)
会修改外部数据*args
**kwargs
转载地址:http://ufnwz.baihongyu.com/