当前位置: 首页 > news >正文

公司做网站需要多少钱ui设计专业

公司做网站需要多少钱,ui设计专业,外包加工网站有哪些,福建省武夷山市城乡建设网站14. 迭代器和迭代协议 在Python中#xff0c;迭代器是支持迭代操作的对象#xff0c;即它们可以一次返回其成员中的一个。任何实现了 __iter__() 和 __next__() 方法的对象都是迭代器。 class Count:def __init__(self, low, high):self.current lowself.high highdef __i…14. 迭代器和迭代协议 在Python中迭代器是支持迭代操作的对象即它们可以一次返回其成员中的一个。任何实现了 __iter__() 和 __next__() 方法的对象都是迭代器。 class Count:def __init__(self, low, high):self.current lowself.high highdef __iter__(self):return selfdef __next__(self):if self.current self.high:raise StopIterationelse:self.current 1return self.current - 1# 使用迭代器 for number in Count(1, 5):print(number)15. 生成器 生成器是一种特殊的迭代器可以更方便地使用简单的函数来创建。通过使用关键字 yield函数在每次生成值时将挂起其状态。 def countdown(n):while n 0:yield nn - 1# 使用生成器 for i in countdown(5):print(i)16. 装饰器的进阶用法 装饰器可以用来修改其他函数的行为而且可以堆叠、参数化。 def decorator_with_args(number):def my_decorator(func):def wrapper(*args, **kwargs):print(Something is happening before the function is called.)result func(*args, **kwargs)print(Something is happening after the function is called.)return result * numberreturn wrapperreturn my_decoratordecorator_with_args(3) def add(x, y):return x yprint(add(2, 3))17. 异步编程asyncio Python的 asyncio 模块用于编写单线程并发代码使用协程适用于IO密集型应用。 import asyncioasync def main():print(Hello)await asyncio.sleep(1)print(world)asyncio.run(main())18. 类型注解 Python从3.5版本开始引入了类型提示type hints用于指示变量和函数参数、返回值的类型有助于代码的可读性和可维护性。 from typing import List, Dictdef greet_all(names: List[str]) - None:for name in names:print(fHello, {name})greet_all([Alice, Bob, Charlie])19. 元编程 元编程是指在运行时创建或自定义代码的技术。Python提供了多种元编程工具包括元类和装饰器。 元类Metaclasses 元类是创建类的类它们允许你拦截Python的类构造过程。通过定义一个元类你可以修改类的定义。 class Meta(type):def __new__(cls, name, bases, class_dict):print(A class is defined with name:, name)return type.__new__(cls, name, bases, class_dict)class MyClass(metaclassMeta):pass# 输出: A class is defined with name: MyClass20. 动态属性和方法 Python支持在运行时动态地添加或修改对象和类的属性和方法这增加了代码的灵活性。 class DynamicClass:pass# 动态添加属性 obj DynamicClass() obj.new_attr Hello print(obj.new_attr)# 动态添加方法 import types def dynamic_method(self):return Dynamic Method Calledobj.dynamic_method types.MethodType(dynamic_method, obj) print(obj.dynamic_method())21. 上下文管理器的高级用法 除了基本的 with 语句用法外你可以创建支持复杂逻辑的自定义上下文管理器。 class ManagedResource:def __enter__(self):print(Enter resource)return selfdef __exit__(self, exc_type, exc_val, exc_tb):print(Exit resource)if exc_type:print(fAn error occurred: {exc_val})return True # Suppress exceptionswith ManagedResource():raise Exception(Something went wrong!) # Enter resource # Exit resource # An error occurred: Something went wrong!22. 多进程与多线程 Python支持多线程和多进程编程这对于提高IO密集型和计算密集型应用的性能非常重要。 多进程 from multiprocessing import Processdef print_func(continentAsia):print(The name of continent is : , continent)if __name__ __main__: # Required for Windowsnames [America, Europe, Africa]procs []proc Process(targetprint_func) # Create a Processprocs.append(proc)proc.start()# Create a process for each namefor name in names:proc Process(targetprint_func, args(name,))procs.append(proc)proc.start()# Complete the processesfor proc in procs:proc.join()多线程 import threadingdef print_cube(num):print(Cube: {}.format(num * num * num))def print_square(num):print(Square: {}.format(num * num))if __name__ __main__:t1 threading.Thread(targetprint_square, args(10,))t2 threading.Thread(targetprint_cube, args(10,))t1.start()t2.start()t1.join()t2.join()
http://www.hkea.cn/news/14494757/

相关文章:

  • 资源网站排名优化seoasp.net网站发布到虚拟主机
  • 800元五合一建站南京蓝牙app开发公司
  • 简洁企业网站源码棋牌网站建设要多少钱
  • iis如何发布asp.net网站做网站备案地点
  • 列出寻找网站关键词的几种途径图片制作的标准是什么
  • 网站中做背景图片位置咋写南宁企业建站系统模板
  • 知名的家居行业网站开发制作一个网站数据库怎么做
  • 找人做网站需要注意什么如何设计公众号
  • 怎样用dw做 网站首页做网站哪些公司好
  • 一个设计网站多少钱wordpress 模板破解版
  • wordpress的网站是php的代码wordpress文章多个分类显示不出来
  • 做网站作品是静态wordpress 多语言插件
  • 做标志的网站网站已备案下一步怎么做
  • 信阳网站设计古玩网站建设意义
  • mvc 网站开发百度竞价排名机制
  • 玩具 网站模板成都农业网站建设
  • 网站被墙了怎么办通州郑州阳网站建设
  • 枣阳网站开发公司哪家好广州模板建站软件
  • 国外设计素材网站如何建设学校门户网站
  • 手机可以开发网站临安建设投标网站
  • 域名是否就是网站在线阅读小说网站怎么建设
  • 用ps做零食网站模板wordpress添加管理员
  • 医疗器械类网站前置审批快速搭建网站前端
  • 免费软件制作网站模板下载软件迅速上排名网站优化
  • 亦庄做网站ppt下载免费完整版
  • 做网站的哪家公司好工业产品设计与创客实践赛题库
  • 建设网站的编程过程linux 什么做网站好
  • 做电器哪个网站好如何做cad图纸模板下载网站
  • 美容网站制作购物商城网站制作
  • ppt超链接至网站怎么做西安凤城二路网站建设