Python3 基础教程 - 廖雪峰com/ 112/531 而节省大量的空间。在 Python 中,这种一边循环一边计算的机制,称 为生成器:generator。 要创建一个 generator,有很多种方法。第一种方法很简单,只要把一个 列表生成式的[]改成(),就创建了一个 generator: >>> L = [x * x for x in range(10)] >>> L [0, 1, 4, 9, 16 g <generator objectat 0x1022ef630> 创建 L 和 g 的区别仅在于最外层的[]和(),L 是一个 list,而 g 是一个 generator。 我们可以直接打印出 list 的每一个元素,但我们怎么打印出 generator 的 每一个元素呢? 如果要一个一个打印出来,可以通过 next()函数获得 generator 的下一个 StopIteration 我们讲过,generator 保存的是算法,每次调用 next(g),就计算出 g 的 下一个元素的值,直到计算到最后一个元素,没有更多的元素时,抛出 StopIteration 的错误。 当然,上面这种不断调用 next(g)实在是太变态了,正确的方法是使用 for 循环,因为 generator 也是可迭代对象: >>> g = (x * x 0 码力 | 531 页 | 5.15 MB | 1 年前3
Django CMS 4.1.x Documentationdjango CMS requires you to set the LANGUAGES [https://docs.djangoproject.com/en/4.2/ref/settings/#std-setting-LANGUAGES] setting. This should list all the languages you want your project to serve, and and must include the language in LANGUAGE_CODE [https://docs.djangoproject.com/en/4.2/ref/settings/#std-setting-LANGUAGE_CODE]. For example: (For simplicity’s sake, at this stage it is worth changing the by default in a new Django project’s DATABASES [https://docs.djangoproject.com/en/4.2/ref/settings/#std-setting-DATABASES]. Note "djangocms_admin_style", LANGUAGES = [ ("en", "English"), ("de",0 码力 | 518 页 | 1.66 MB | 6 月前3
Django CMS 2.4.x Documentationhtml#std:setting-MIDDLEWARE_CLASSES]: cms.middleware.media.PlaceholderMediaMiddleware Remove the following from INSTALLED_APPS [http://readthedocs.org/docs/django/en/latest/ref/settings.html#std:sett Add the following to INSTALLED_APPS [http://readthedocs.org/docs/django/en/latest/ref/settings.html#std:setting-INSTALLED_APPS]: sekizai django.contrib.staticfiles Template Updates Make sure to add sekizai static files into your STATIC_ROOT [http://readthedocs.org/docs/django/en/latest/ref/settings.html#std:setting-STATIC_ROOT]: python manage.py collectstatic django cms 2.4.3-support documentation » © Copyright0 码力 | 156 页 | 727.78 KB | 6 月前3
django cms 3.4.x Documentationdjango CMS requires you to set the LANGUAGES [https://docs.djangoproject.com/en/1.10/ref/settings/#std:setting-LANGUAGES] setting. This should list all the languages you want your project to serve, and and must include the language in LANGUAGE_CODE [https://docs.djangoproject.com/en/1.10/ref/settings/#std:setting-LANGUAGE_CODE]. For example: LANGUAGES = [ ('en', 'English'), ('de', 'German'), ] default in a new Django project’s DATABASES [https://docs.djangoproject.com/en/1.10/ref/settings/#std:setting-DATABASES]. Note For deployment, you’ll need to use a production-ready database with Django0 码力 | 395 页 | 1.64 MB | 1 年前3
django cms 3.5.x Documentationdjango CMS requires you to set the LANGUAGES [https://docs.djangoproject.com/en/1.10/ref/settings/#std:setting-LANGUAGES] setting. This should list all the languages you want your project to serve, and and must include the language in LANGUAGE_CODE [https://docs.djangoproject.com/en/1.10/ref/settings/#std:setting-LANGUAGE_CODE]. For example: LANGUAGES = [ ('en', 'English'), ('de', 'German'), ] default in a new Django project’s DATABASES [https://docs.djangoproject.com/en/1.10/ref/settings/#std:setting-DATABASES]. Note For deployment, you’ll need to use a production-ready database with Django0 码力 | 403 页 | 1.69 MB | 1 年前3
django cms 3.7.x Documentationdjango CMS requires you to set the LANGUAGES [https://docs.djangoproject.com/en/2.2/ref/settings/#std:setting-LANGUAGES] setting. This should list all the languages you want your project to serve, and and must include the language in LANGUAGE_CODE [https://docs.djangoproject.com/en/2.2/ref/settings/#std:setting-LANGUAGE_CODE]. For example: LANGUAGES = [ ('en', 'English'), ('de', 'German'), ] default in a new Django project’s DATABASES [https://docs.djangoproject.com/en/2.2/ref/settings/#std:setting-DATABASES]. Note For deployment, you’ll need to use a production-ready database with Django0 码力 | 409 页 | 1.67 MB | 1 年前3
Django CMS 3.9.x Documentationdjango CMS requires you to set the LANGUAGES [https://docs.djangoproject.com/en/2.2/ref/settings/#std:setting-LANGUAGES] setting. This should list all the languages you want your project to serve, and and must include the language in LANGUAGE_CODE [https://docs.djangoproject.com/en/2.2/ref/settings/#std:setting-LANGUAGE_CODE]. For example: LANGUAGES = [ ('en', 'English'), ('de', 'German'), ] by default in a new Django project’s DATABASES [https://docs.djangoproject.com/en/2.2/ref/settings/#std:setting-DATABASES]: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3',0 码力 | 417 页 | 1.68 MB | 6 月前3
Django CMS 3.8.x Documentationdjango CMS requires you to set the LANGUAGES [https://docs.djangoproject.com/en/2.2/ref/settings/#std:setting-LANGUAGES] setting. This should list all the languages you want your project to serve, and and must include the language in LANGUAGE_CODE [https://docs.djangoproject.com/en/2.2/ref/settings/#std:setting-LANGUAGE_CODE]. For example: LANGUAGES = [ ('en', 'English'), ('de', 'German'), ] by default in a new Django project’s DATABASES [https://docs.djangoproject.com/en/2.2/ref/settings/#std:setting-DATABASES]. Note For deployment, you’ll need to use a production-ready database with Django0 码力 | 413 页 | 1.67 MB | 6 月前3
django cms 3.3.x DocumentationAdd the following apps to your INSTALLED_APPS [https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-INSTALLED_APPS]. This includes django CMS itself as well as its dependencies and other highly default cms_page_media/ relative to MEDIA_ROOT [https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-MEDIA_ROOT]) is writeable by the user under which Django will be running. If you have opted com/etianen/django-reversion] and add it to INSTALLED_APPS [https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-INSTALLED_APPS]: 'reversion' You need to add the django CMS middlewares to your MIDDLEWARE_CLASSES0 码力 | 386 页 | 1.56 MB | 1 年前3
Tornado 6.1 Documentation
tornado.tcpserver — Basic IOStream-based TCP server Coroutines and concurrency tornado.gen — Generator-based coroutines tornado.locks – Synchronization primitives tornado.queues – Queues for coroutines yield is a generator. All generators are asynchronous; when called they return a generator object instead of running to completion. The @gen.coroutine decorator communicates with the generator via the yield decorator receives a Future from the generator, waits (without blocking) for that Future to complete, then “unwraps” the Future and sends the result back into the generator as the result of the yield expression0 码力 | 931 页 | 708.03 KB | 1 年前3
共 319 条
- 1
- 2
- 3
- 4
- 5
- 6
- 32













