res

抢票小程序

◇◆丶佛笑我妖孽 提交于 2019-11-29 22:15:24
抢票小程序 我们可以利用所学的内容来写一个简易的抢票小程序 from multiprocessing import Process import json,time,os def search(): time.sleep(1) # 模拟网络io with open('db.txt',mode='rt',encoding='utf-8') as f: res = json.load(f) print(f'还剩{res["count"]}') def get(): with open('db.txt',mode='rt',encoding='utf-8') as f: res = json.load(f) # print(f'还剩{res["count"]}') time.sleep(1) # 模拟网络io if res['count'] > 0: res['count'] -= 1 with open('db.txt',mode='wt',encoding='utf-8') as f: json.dump(res,f) time.sleep(1.5) # 模拟网络io print(f'进程{os.getpid()} 抢票成功') else: print('票已经售空啦!!!!!!!!!!!') def task(): search() get() if __name__ == '_

2019-09-17 thinkphp网页静态化

瘦欲@ 提交于 2019-11-29 21:58:04
public function details(){ $pid = I('get.goods_id'); $filename = "details_".$pid.".html"; if(file_exists($filename)){ echo file_get_contents($filename); }else{ ob_start(); require("/store/Store/Home/View/category/details_model.html"); $str = ob_get_contents(); ob_end_clean(); $data['goods_id']= I('get.goods_id'); $goods = M('goods'); $res = $goods->where($data)->find(); $str = str_replace('{$goods_data.goods_name}',$res['goods_name'],$str); $str = str_replace('{$goods_data.market_price}',$res['market_price'],$str); $str = str_replace('{$goods_data.goods_price}',$res['goods_price'],$str); $str

jquery让form表单异步提交

拈花ヽ惹草 提交于 2019-11-29 21:29:11
1.监听表单提交事件,并阻止表单提交 $("form").submit(function(e) { return false;//阻止表单提交 }) 2.拿到表单内容 let data = $("form").serialize(); //上边这个就是拿到表单的内容,如果你想要json格式,就要自己去处理 //hdxh=1&name=%E5%BC%A0%E4%B8%89 //直接拼在url后边 $.ajax({ url:"xxx"+"?"+data, success:res=>{ console.log(res{ } }) 3.所以完整代码为: $("form").submit(function(e) { let data = $("form").serialize(); $.ajax({ url:"xxx"+"?"+data, success:res=>{ console.log(res{ } }) return false;//阻止表单提交 }) 来源: https://www.cnblogs.com/Lyn4ever/p/11533340.html

抢票小程序

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 19:13:53
抢票小程序 我们可以利用所学的内容来写一个简易的抢票小程序 from multiprocessing import Process import json,time,os def search(): time.sleep(1) # 模拟网络io with open('db.txt',mode='rt',encoding='utf-8') as f: res = json.load(f) print(f'还剩{res["count"]}') def get(): with open('db.txt',mode='rt',encoding='utf-8') as f: res = json.load(f) # print(f'还剩{res["count"]}') time.sleep(1) # 模拟网络io if res['count'] > 0: res['count'] -= 1 with open('db.txt',mode='wt',encoding='utf-8') as f: json.dump(res,f) time.sleep(1.5) # 模拟网络io print(f'进程{os.getpid()} 抢票成功') else: print('票已经售空啦!!!!!!!!!!!') def task(): search() get() if __name__ == '_

优化抢票

跟風遠走 提交于 2019-11-29 19:11:21
优化抢票 from multiprocessing import Process,Lock import json,time,os def search(): time.sleep(1) # 模拟网络io with open('db.txt',mode='rt',encoding='utf-8') as f: res = json.load(f) print(f'还剩{res["count"]}') def get(): with open('db.txt',mode='rt',encoding='utf-8') as f: res = json.load(f) # print(f'还剩{res["count"]}') time.sleep(1) # 模拟网络io if res['count'] > 0: res['count'] -= 1 with open('db.txt',mode='wt',encoding='utf-8') as f: json.dump(res,f) print(f'进程{os.getpid()} 抢票成功') time.sleep(1.5) # 模拟网络io else: print('票已经售空啦!!!!!!!!!!!') def task(lock): search() # 锁住 lock.acquire() get() lock.release()

微信小程序 wx.request 请求方法封装

只愿长相守 提交于 2019-11-29 18:56:56
// request请求的封装 module.exports = { postJson: function(url, data) { var params = data; params.token = wx.getStorageSync('token'); //返回一个promise实例 return new Promise((resolve, reject) => { wx.request({ url: url, data: params, method: 'POST', header: { 'content-type': "application/x-www-form-urlencoded" }, success: function(res) { console.log(res) //这里可以拦截一些公共的code码 比如 登录过期之类的 resolve(res ? res.data : res) }, fail: function(res) { // console.log(res) reject(res ? res.data : res); }, complete: function(res) { // console.log(res) } }) }) }, getJson: function(url, data) { //返回一个promise实例 var params

p4151 [WC2011]最大XOR和路径

断了今生、忘了曾经 提交于 2019-11-29 14:31:32
分析 我们发现任取条路径 对于路径外的环一定可以将它完整的取到 而对于和路径有交的环相当于用一段新路径代替原来的一段路径 所以我们只需求出任意一个1到n的路径和图上所有环的值 然后借助线性基求出异或最大值即可 代码 #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<cctype> #include<cmath> #include<cstdlib> #include<queue> #include<ctime> #include<vector> #include<set> #include<map> #include<stack> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back #define li long long vector<pair<int,li> >v[100100]; int n,m,vis[100100]; li bel[110],d[100100],ans; inline void ins(li x){ for(int i=63;i>=0;i--) if((1ll<<i)

抢票小程序

僤鯓⒐⒋嵵緔 提交于 2019-11-29 10:19:36
from multiprocessing import Process import json,time,os def search(): time.sleep(1) with open('db.txt','rt',encoding='utf8') as f: res=json.load(f) print(f'还剩{res["count"]}') def get(): with open('db.txt','rt',encoding='utf8')as f: res=json.load(f) time.sleep(1) if res['count']>0: res['count']-=1 with open('db.txt','wt',encoding='utf8')as f: json.dump(res,f) time.sleep(1.5) print(f'进程{os.getpid()}抢票成功') else: print('票已经售空了') def task(): search() get() if __name__ == '__main__': for i in range(10): p=Process(target=task) p.start() p.join() # 为了保证数据的安全,要牺牲掉效率. 来源: https://www.cnblogs.com/aden668

nodejs,express链式反应

痴心易碎 提交于 2019-11-29 06:19:33
链式反应--next() const myexpress = require('express'); const bodyparser = require('body-parser'); var server = myexpress(); server.listen(8080); server.use('/',function (req,res,next) { console.log('a'); req.name = "陈培昌"; next() }); server.use('/',function (req,res,next){ console.log('b'); req.intro = req.name+"芳龄"+22; next(); }); server.use('/',function (req,res,next) { console.log(req.intro) }); 上机结果: a b 陈培昌芳龄22 来源: https://www.cnblogs.com/saintdingspage/p/11458774.html

【洛谷 P5180】【模板】—支配树(拓扑排序+带权并查集)

天涯浪子 提交于 2019-11-29 05:46:16
传送门 补模板,并没有题解 不会 O ( n α ) O(n\alpha) O ( n α ) 的 L e n g a u e r − T a r j a n Lengauer-Tarjan L e n g a u e r − T a r j a n 算法 反正据说常数很大 虽然 O ( n l o g n ) O(nlogn) O ( n l o g n ) 要倍增 L c a Lca L c a 也很慢 感觉要记一大堆东西还是十分蛋疼 # include <bits/stdc++.h> using namespace std ; const int RLEN = 1 << 20 | 1 ; inline char gc ( ) { static char ibuf [ RLEN ] , * ib , * ob ; ( ob == ib ) && ( ob = ( ib = ibuf ) + fread ( ibuf , 1 , RLEN , stdin ) ) ; return ( ob == ib ) ? EOF : * ib ++ ; } # define gc getchar inline int read ( ) { char ch = gc ( ) ; int res = 0 , f = 1 ; while ( ! isdigit ( ch ) ) f ^ = ch