Python

python 显示上午下午

 importtimeimportdatetimei=datetime.datetime.now()prefix='''>**接口报警**>日 期:<fontcolor="info">{}年{}月{}日</font>>时 间:<fontcolor="info"&...
代码星球·2020-11-02

python实现简单的http服务器

 index.html<!DOCTYPEhtml><htmlxmlns="http://www.w3.org/1999/xhtml"xml:lang="en"lang="en"><head><title>UntitledDocument</title>...

python 的串行和并行

 importasyncioimporttime#串行#asyncio.run()asyncdefsay_after(delay,what):awaitasyncio.sleep(delay)print(what)asyncdefmain():print(f"startedat{time.strftime('...
代码星球·2020-11-02

python 获取时分秒

 importtimeimportdatetimei=datetime.datetime.now()prefix='''>**接口报警**>日 期:<fontcolor="info">{}年{}月{}日</font>>时 间:<fontcolor="info"&...
代码星球·2020-11-02

python urlencode

 >>>importurllib.parse>>>>>>d={"name":"浙椒渔92017"}>>>data=urllib.parse.urlencode(d)>>>data'name=%E6%B5%99%E6%A4...
代码星球·2020-11-02

python计算当前时间的前(后)一分钟,前(后)一小时,前(后)一天

 #计算当前时间importdatetimedatetime.datetime.now()#2019-06-3010:51:14.089271#格式化时间datetime.datetime.now().strftime("%Y-%m-%d%H:%M:%S")#2019-06-3010:52:05#多加(减)一...

python 获取日期以及时间

 >>>importdatetime>>>>>>i=datetime.datetime.now()>>>print(i.year,i.month,i.day,i.hour,i.minute,i.second)20201222061226&...

Python3 使用企业微信 API 发送消息

 #coding=utf-8importrequestsimportjsonSecret="TUbfeW8nFQakwOS4czm13SCnxSUPOqY2K0XHtM8XLT34"corpid='wwfe776a5bc7b90190a'url='https://qyapi.weixin.qq.com/cgi...

python3 获取当前日期的时间戳,以及n天后的日期时间戳

 #coding=utf-8importtimeimportdatetimet=datetime.datetime.now()#当前日期t1=t.strftime('%Y-%m-%d00:00:00')#转为秒级时间戳start_time=time.mktime(time.strptime(t1,'%Y-%m...

python实现的WebSocket客户端

code#coding=utf-8importjsonimporttimefromwebsocketimportcreate_connectionws=create_connection("ws://x.x.x.x:8090/haiyou/device")print("Sending'Hello,World'...")...

python3 修改excel 单元格的值(xlsx)

excel  code #coding=utf-8importos.pathimportosfromopenpyxl.reader.excelimportload_workbook#excel文件绝对路径file_home="./xls/modify/name.xlsx"wb=load_w...

python requests 上传excel数据流

      headers=self.headers#获取导入模版file_home=self.import_templatelog.info(file_home)wb=load_workbook(filename=file_home)ws=wb['sheet1']#修改产废单位名称,以及备注ws['b3']...

python3 获取日期时间

 #!/usr/bin/python3importtime#格式化成2016-03-2011:45:39形式print(time.strftime("%Y-%m-%d%H:%M:%S",time.localtime()))#格式化成SatMar2822:24:242016形式print(time.strfti...
代码星球·2020-11-01

python3 ini文件读写

 importconfigparserconfig=configparser.ConfigParser()file='config.ini'config.read(file)config.add_section('login')config.set('login','username','1111')conf...
代码星球·2020-11-01

python3 mqtt 添加用户名以及密码

 importpaho.mqtt.clientasmqttclient=mqtt.Client(client_id,transport='tcp')client.username_pw_set(username,password=passwd)参考:https://www.cnblogs.com/chenpi...