摘要:
from random import shuffle mylist=[0,1,2,3,4,5,6,7,8] shuffle(mylist) print(mylist) 阅读全文
摘要:
mylist=[0,1,2,3,4,5] a=mylist[-1]#负索引和正索引不同,他是从右边开始检索 b=mylist[-3:-1] #还能用于列表中的切片print(a)#5 print(b)#[3,4] 阅读全文
摘要:
import os os.chdir(r'C:\Users\Administrator\Desktop')#os.chdir切换到指定目录 with open('a.txt') as today: count=0 for i in today.read(): if i.isupper(): count+=1 print(count)... 阅读全文
摘要:
当我们不知道向函数传递多少参数时,比如我们向传递一个列表或元组,我们就使用*args 32147 当我们不知道该传递多少关键字参数时,使用**kwargs来收集关键字参数 阅读全文
摘要:
roots={x**2:x for x in range(5,0,-1)} print(roots) #{25: 5, 16: 4, 9: 3, 4: 2, 1: 1} 阅读全文
摘要:
有返回值的是不可变的 没返回值的是可变的 阅读全文
摘要:
123 阅读全文
摘要:
答案是no,循环引用其他对象或引用自全局命名空间的对象的模块,在python退出时并非完全释放 另外,也不会释放c库保留的内存部分 阅读全文
摘要:
help函数是一个内置函数,用于查看函数或模块用途的详细说明 Help on function copy in module copy: copy(x) Shallow copy operation on arbitrary Python objects. See the module's __do 阅读全文
摘要:
python有一个私有堆空间来保存所有的对象和数据结构。作为开发者,我们无法访问它,是解释器在管理它,但是有了核心api后,我们可以访问一些工具。python内存管理器控制内存分配 内置垃圾回收器会回收使用所有的未使用内存,所以使其适用于堆空间 阅读全文