本文共 1701 字,大约阅读时间需要 5 分钟。
单行注释:#
"""" 或 '''' + 加 - 减 * 乘 / 除 // 整除 % 余数 ** 幂
注意:
bool:非零为真,0为假int:整数float:浮点数complex:复数(a=complex(real, imag))注意:
int(), float(), complex()+ 或 *hello_worldhelloWorld(首字母小写,后续首字母大写)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, tuplelist, dictid() 获取引用地址hash() 方法
global声明def语句returndef demo(name, gender=True)*args, **kwargsnum_list.append(88) 会修改外部数据*args**kwargs转载地址:http://ufnwz.baihongyu.com/