当前位置: 网站首页>小程序开发>400电话办理

龙海企业网站设计 - 龙海高端网站定制 - 龙海品牌网站搭建 - 上往建站

发表日期: 2022-07-03 16:08:35 浏览次数:47

龙海企业网站设计 - 龙海高端网站定制 - 龙海品牌网站搭建 - 上往建站

网站建设.png


rial: Helvetica的「克隆」,和Helvetica非常像,细节上比如R和G有小小差别。如果字号太小,文字太多,看起来会有些累眼。Win和Mac显示都正常.Lucida Family: Lucida Grande是Mac OS UI的标准字体,属于humanist风格,稍微活泼一点。Mac下的显示要比Win下好。

Verdana: 专门为了屏显而设计的字体,humanist风格,在小字号下仍可以清楚显示,但是字体细节缺失严重,最好别做标题。

Tahoma: 也是humanist风格,字体和Verdana有点像,但是略窄一些,counter略小,曾经是Windows的标准字体,Mac 10.5之后默认也有安装。

Trebuchet MS: 为微软设计的一个humanist风格字体,个人觉得个性太过突出,用得不好会不搭。


  1. def get():
        m = 0
        n = 2
        l = ['s',1,3]
        k = {1:1,2:2}
        p = ('2','s','t')
        while True:
            m += 1
            yield m        yield m ,n ,l ,k ,p
            
    it = get()print(next(it)) #1print(next(it)) #(1, 2, ['s', 1, 3], {1: 1, 2: 2}, ('2', 's', 't'))print(next(it)) #2print(type(next(it))) #<class 'tuple'>

    如果再加一句:

    print(type(next(it))) #<class 'int'>  #返回的是整形

    所以返回值的类型,应该是当前调用时,yield 返回值的类型。

    怀雨

       怀雨

      522***18@qq.com

    4年前 (2018-05-05)
  2.    hid4net

      hid***t@qq.com

    61

    感谢楼上各位的实例,自己写了一个小例程,便于我这样的新手理解。

    def myYield_1():
        a, i = 'yield', 0
        while True:
            print('before #%d' % i, end=", ")
            yield a, i        print('after #%d' % i, end=", ")
            i += 1def myYield_2():
        a, i = 'yield_a', 0
        b, i = 'yield_b', 0
        while True:
            print('before #%d' % i, end=", ")
            yield a, i        yield b, i        print('after #%d' % i, end=", ")
            i += 1it1 = iter(myYield_1())it2 = iter(myYield_2())for i in range(10):
        print("next #%d" % i, end=": ")
        print(next(it1))print('\n')for i in range(10):
        print("next #%d" % i, end=": ")
        print(next(it2))

    输出是这样的:

    next #0: before #0, ('yield', 0)next #1: after #0, before #1, ('yield', 1)next #2: after #1, before #2, ('yield', 2)next #3: after #2, before #3, ('yield', 3)next #4: after #3, before #4, ('yield', 4)next #5: after #4, before #5, ('yield', 5)next #6: after #5, before #6, ('yield', 6)next #7: after #6, before #7, ('yield', 7)next #8: after #7, before #8, ('yield', 8)next #9: after #8, before #9, ('yield', 9)next #0: before #0, ('yield_a', 0)next #1: ('yield_b', 0)next #2: after #0, before #1, ('yield_a', 1)next #3: ('yield_b', 1)next #4: after #1, before #2, ('yield_a', 2)next #5: ('yield_b', 2)next #6: after #2, before #3, ('yield_a', 3)next #7: ('yield_b', 3)next #8: after #3, before #4, ('yield_a', 4)next #9: ('yield_b', 4)
    hid4net

       hid4net

      hid***t@qq.com

    4年前 (2018-09-16)
  3.    really

      nin***ally9@gmail.com

       参考地址

    26

    前文提到:字符串,列表或元组对象都可用于创建迭代器。

    字符串(Strings):

    普通的旧字符串也是可迭代的。

    for s in "hello":
        print s

    输出结果为:

    h
    e
    l
    l
    o

    列表(Lists):

    这些可能是最明显的迭代。

    for x in [None,3,4.5,"foo",lambda : "moo",object,object()]:
        print "{0}  ({1})".format(x,type(x))

    输出结果为:

    None  (<type 'NoneType'>)3  (<type 'int'>)4.5  (<type 'float'>)foo  (<type 'str'>)<function <lambda> at 0x7feec7fa7578>  (<type 'function'>)<type 'object'>  (<type 'type'>)<object object at 0x7feec7fcc090>  (<type 'object'>)

    元组(Tuples):

    元组在某些基本方面与列表不同,注意到以下示例中的可迭代对象使用圆括号而不是方括号,但输出与上面列表示例的输出相同。

    for x in (None,3,4.5,"foo",lambda : "moo",object,object()):
        print "{0}  ({1})".format(x,type(x))

    输出结果为:

    None  (<type 'NoneType'>)3  (<type 'int'>)4.5  (<type 'float'>)foo  (<type 'str'>)<function <lambda> at 0x7feec7fa7578>  (<type 'function'>)<type 'object'>  (<type 'type'>)<object object at 0x7feec7fcc090>  (<type 'object'>)

    字典(Dictionaries):

    字典是键值对的无序列表。当您使用for循环遍历字典时,您的虚拟变量将使用各种键填充。

    d = {
      'apples' : 'tasty',
      'bananas' : 'the best',
      'brussel sprouts' : 'evil',
      'cauliflower' : 'pretty good'}for sKey in d:
      print "{0} are {1}".format(sKey,d[sKey])

    输出结果为:

    brussel sprouts are evil
    apples are tasty
    cauliflower are pretty good
    bananas are the best

    也许不是这个顺序,字典是无序的!!!

    really

       really

      nin***ally9@gmail.com

       参考地址

    3年前 (2019-01-26)
  4.    wuguandong

      963***591@qq.com

    15

    使用自定义迭代器实现斐波那契数列

    class Fibonacci:
      def __init__(self, count):
        self.count = count  def __iter__(self):
        self.i = 0
        self.a, self.b = 0, 1
        return self
    
      def __next__(self):
      if self.i < self.count:
        self.i += 1
        a_old = self.a    self.a, self.b = self.b, self.a + self.b    return a_old  else:
        raise StopIterationfor i in Fibonacci(10):
      print(i, end=" ")
    wuguandong

       wuguandong

      963***591@qq.com

    3年前 (2019-08-21)
  5.    闫伟超

      yif***chaoran@163.com

    70

    如教程所说,迭代器和生成器算是 Python 一大特色,其核心是基于迭代器协议来的。

    而平时我们经常使用的 for in 循环体,本质就是迭代器协议的一大应用。

    同时 Python 内置的集合类型(字符、列表、元组、字典)都已经实现了迭代器协议,所以才能使用 for in 语句进行迭代遍历。for in 循环体在遇到 StopIteration 异常时,便终止迭代和遍历。

    再说下可迭代、迭代器、生成器三个概念的联系和区别。

    1、可迭代概念范围最大,生成器和迭代器肯定都可迭代,但可迭代不一定都是迭代器和生成器,比如上面说到的内置集合类数据类型。可以认为,在 Python 中,只要有集合特性的,都可迭代。

    2、迭代器,迭代器特点是,均可以使用 for in 和 next 逐一遍历。

    3、生成器,生成器一定是迭代器,也一定可迭代。

    至于 Python 中为何

龙海企业网站设计 - 龙海高端网站定制 - 龙海品牌网站搭建 - 上往建站

400-111-6878
服务热线
顶部

备案号: 苏ICP备11067224号

CopyRight © 2011 书生商友信息科技 All Right Reserved

24小时服务热线:400-111-6878   E-MAIL:1120768800@qq.com   QQ:1120768800

  网址: https://www.768800.com  网站建设上往建站

关键词: 网站建设| 域名邮箱| 服务器空间| 网站推广| 上往建站| 网站制作| 网站设计| 域名注册| 网络营销| 网站维护|

企业邮箱| 虚拟主机| 网络建站| 网站服务| 网页设计| 网店美工设计| 网站定制| 企业建站| 网站设计制作| 网页制作公司|

400电话办理| 书生商友软件| 葬花网| 调温纤维| 海洋馆运营维护| 北京保安公司| 殡仪馆服务| 殡葬服务| 昌平殡葬| 朝阳殡葬|

预约专家

欢迎您免费咨询,请填写以下信息,我们收到后会尽快与您联系

  

服务热线:400-111-6878