#!/usr/bin/env python # -*- coding:utf-8 -*- #Author:ersa ''' #f,文件句柄;模式 a : append 追加文件内容 f = open("yesterday2",'a',encoding="utf-8") f.write("\nWhen i was yount i listen to the radio\n") f.write("I love Beijing Tiananm…
for#列表生成式 data = [1,2,3,4,5,6,7] #####列表生成式 #data = [i+1 for i in data] data = [i*2 if i>5 else i for i in data] print(data) data = [i//2 if i>4 else i for i in data] print(data) 1.生成器yield a #返回a,同时挂起当前这个函数yield a #返回a, 同时挂起当前这个函数, a返回给了通过__next__(…