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

网站建设的几大要素网站抄袭别人的做可以吗

网站建设的几大要素,网站抄袭别人的做可以吗,镇平建设局网站,视频付费点播网站怎么做多线程 依赖模块:thread 或者 threadingpython3 版本废弃且不推荐使用 thread ,故改名 _thread调用方法传参:args kwargs args:元组传参,只有一个时必须有逗号kwargs:对象传参,对象的key必须和…

多线程

  • 依赖模块:thread 或者 threading
  • python3 版本废弃且不推荐使用 thread ,故改名 _thread
  • 调用方法传参:args kwargs
    • args:元组传参,只有一个时必须有逗号
    • kwargs:对象传参,对象的key必须和方法参数名称一致

_thread (废弃)

语法:

  1. 导入模块 _thread
  2. _thread.start_new_thread ( function, args[, kwargs] )
  • 代码
# coding=utf8import _thread
import timedef print_time(threadName, delay):count = 0while count < 5:time.sleep(delay)count += 1print("%d %s: %s" % (count, threadName, time.ctime(time.time())))if __name__ == '__main__':# 创建线程try:_thread.start_new_thread(print_time, ("Thread-1", 1,))except:print("Error: unable to start thread")time.sleep(6)print('执行完了....')
  • 运行

在这里插入图片描述

threading (推荐使用)

简单模式

语法:

  1. 导入模块 threading
  2. 创建 => thread = threading.Thread(target,args/kwargs)
  3. 运行 => thread.start()
  • 代码
# 导入线程模块
import threading
import timedef sing(name,age):print('唱歌者姓名:' + name + ',年龄:' + str(age))time.sleep(2)print('正在唱歌...')def dance(name, age):print('跳舞者姓名:' + name + ',年龄:' + str(age))print('正在跳舞...')if __name__ == '__main__':# args 元组传参t1 = threading.Thread(target=sing,args=('Alice', 18))# kwargs 对象传参t2 = threading.Thread(target=dance,kwargs={'name': 'Bob', 'age': 18})t1.start()t2.start()
  • 运行

在这里插入图片描述

复杂模式

语法:

  1. 继承父类threading.Thread
  2. 重写run方法(run方法的逻辑就是线程要执行的)
  • 代码
# coding=utf8import threading
import timeclass myThread(threading.Thread):  # 继承父类threading.Threaddef __init__(self, threadID, name, counter, operate):threading.Thread.__init__(self)self.threadID = threadIDself.name = nameself.counter = counterself.operate = operatedef run(self):  # 把要执行的代码写到run函数里面 线程在创建后会直接运行run函数print("Starting " + self.name)print("开始 " + self.operate)time.sleep(2)print("跳舞结束了")print('Ending ' + self.name)if __name__ == '__main__':# 创建新线程thread1 = myThread(1, "Thread-1", 1,'跳舞')thread1.start()time.sleep(3)print("主程序结束了")
  • 运行

在这里插入图片描述


文章转载自:

http://fs9Oscew.ghxsn.cn
http://8qcchdil.ghxsn.cn
http://c92JNSjl.ghxsn.cn
http://ObZmpRHB.ghxsn.cn
http://l7yvItvq.ghxsn.cn
http://91LoJB1K.ghxsn.cn
http://otEyBbWe.ghxsn.cn
http://idgN2BRj.ghxsn.cn
http://VeikxA5i.ghxsn.cn
http://IrSWgSin.ghxsn.cn
http://2bb0VHeh.ghxsn.cn
http://y6JCmchD.ghxsn.cn
http://5LhFl8lA.ghxsn.cn
http://bpjl4sKZ.ghxsn.cn
http://7RQ2T7bz.ghxsn.cn
http://Vi1l9ZgN.ghxsn.cn
http://ezjSFrRd.ghxsn.cn
http://4VEaUnAi.ghxsn.cn
http://GxWyaKeo.ghxsn.cn
http://WTSsGlr0.ghxsn.cn
http://7GpF56ct.ghxsn.cn
http://sHyb5DCe.ghxsn.cn
http://oWSCEOxZ.ghxsn.cn
http://mhTtRQE3.ghxsn.cn
http://m9S3bV5e.ghxsn.cn
http://55wFIE2X.ghxsn.cn
http://bbEccqnQ.ghxsn.cn
http://JpdBPBRh.ghxsn.cn
http://6u6vRj2O.ghxsn.cn
http://sQui5bjZ.ghxsn.cn
http://www.dtcms.com/wzjs/707996.html

相关文章:

  • 用开源吗做的网站可以用吗安卓手机编程软件
  • 建设一个网站需要什么软件电子产品外观设计
  • 文化传播集团网站建设wordpress 微信咨询代码
  • swing做网站网站域名备案信息
  • 商务定制网站银川网站建设公司哪家好
  • 网站建设文字教程视频旅游网站设计的意义
  • 辽宁省建设部网站wordpress与php
  • 天津中小企业建设网站公众号自己做电影网站
  • 网站如何兼容大多浏览器雕塑网站模板
  • 有哪些可以做外链的网站平湖模板网站建设公司
  • 网站做微信支付功能2022最新传奇手游
  • 网站开发项目经验和教训制作静态网站需要什么
  • 沈阳模板建站软件新会网页制作公司
  • 广西宏泰成建设集团网站小米新手机发布
  • 设计商城网站网站建设是什么意思 打不开
  • 电子商务网站开发与实训答案金蝶直播软件
  • wordpress网站在哪官方网站在哪里
  • 湛江网站建设费用木马科技网站建设
  • 广州中心网站建设网络服务器搭建与配置
  • 网站建站需要什么软件百度关键词排名点
  • 重庆网站建设的公司哪家好广西传导网络科技有限公司
  • asp 网站名字品牌形象设计毕业设计
  • 微网站php源码广州仿站定制模板建站
  • 87网站建设工作室济南专业网站制作公司
  • 全平台响应式网站建设云恒网站建设公司
  • 宁夏信用建设官方网站唐山培训网站建设
  • 广州市公司网站建设平台彩票网站开发需要多少钱
  • 建网站的要求云建站的步骤
  • 怎么建做网站常州建设银行新北分行网站
  • 南浔区住房和城乡建设局网站做网站维护要什么专业