摘要:
filter(function or None, iterable) --> filter object Return an iterator yielding those items of iterable for which function(item) is true. If function 阅读全文
摘要:
filter(function or None, iterable) --> filter object Return an iterator yielding those items of iterable for which function(item) is true. If function 阅读全文
摘要:
有一列表,某一元素在列表中出现多次,要求求出该元素在列表中的索引位置。 最简单的方案就是直接对所有元素进行遍历。这里不考虑。 1 # coding:utf-8 2 name = list('12345242523552623623') 3 4 first_pos = 0 5 for i in ran 阅读全文
摘要:
要求,从用户处得到一个数,打印直到该数,并让用户选择是否继续。如果此数已经输出,则提示过了,并要求再次输入。 阅读全文
摘要:
1 import urllib.request 2 import re 3 import random 4 5 def get_source(key): 6 7 print('请稍等,爬取中....') 8 headers = [{'User-Agent':'Mozilla/5.0 (Windows 阅读全文
摘要:
1 #python 字典实现类似c的switch 2 3 def print_hi(): 4 print('hi') 5 6 def print_hello(): 7 print('hello') 8 9 def print_goodbye(): 10 print('goodbye') 11 12 choice = int(input('plea... 阅读全文
摘要:
python里的赋值都是引用,第一次赋值就是定义。 看下面两个交换值的例子: 1. 2. 初一看,很奇怪,这两种交换怎么会不一样呢? 简单点理解就是第一种是按顺序交换,但第2种是同时交换。 python的这种引用机制类似于c语言的指针。 a = 1 即a 引用1 这个值(a指向1) 情境1:a,b, 阅读全文
摘要:
这里通过 映射操作符'**'将当前还在操作范围内的element,number传递给函数locals() 阅读全文
摘要:
已实现基本功能,显示行号功能暂时实现不了(后面学会了再加,右下角可以实现定位光标所在行.列) 可能会有些bug 1 from tkinter import * 2 from tkinter.messagebox import * 3 from tkinter.filedialog import * 4 from threading import Timer 5 import s... 阅读全文
摘要:
1 #coding=utf-8 2 class Fruit:#定义一个类 3 def __init__(self,color): 4 self.color=color 5 print("fruit's color:' %s" % self.color) 6 7 def grow(self): 8 p... 阅读全文
|