上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 20 下一页
摘要: from threading import Thread,Lockimport timea=10b=10lock=Lock()def fun(): # lock.acquire() global a global b a+=1 time.sleep(1) b+=1 # lock.release() 阅读全文
posted @ 2020-03-22 00:36 腹肌猿 阅读(274) 评论(0) 推荐(0) 编辑
摘要: #进程间通信,队列 from multiprocessing import Process,Queue import os,sys import time q=Queue() def get(data): time.sleep(2) print("thread {} get {}".format(o 阅读全文
posted @ 2020-03-22 00:06 腹肌猿 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 一.直接使用TestCase import unittest class Test1(unittest.TestCase): @classmethod def setUpClass(self): print("execute setUpClass") @classmethod def tearDow 阅读全文
posted @ 2020-03-19 00:03 腹肌猿 阅读(647) 评论(0) 推荐(0) 编辑
摘要: JSON (JavaScript Object Notation) 是一种轻量级的数据交换格式。它基于ECMAScript的一个子集。 Python3 中可以使用 json 模块来对 JSON 数据进行编解码,它包含了两个函数: json.dumps(): 对数据进行编码。字典->字符串 json. 阅读全文
posted @ 2020-03-16 00:52 腹肌猿 阅读(221) 评论(0) 推荐(0) 编辑
摘要: >>> s="{'name':'Tom'}" >>> type(s) <class 'str'> >>> json.loads(s) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Pro 阅读全文
posted @ 2020-03-16 00:15 腹肌猿 阅读(2021) 评论(0) 推荐(0) 编辑
摘要: tcp_server from socket import * import threading address='127.0.0.1' #监听哪些网络 127.0.0.1是监听本机 0.0.0.0是监听整个网络 port=9999 #监听自己的哪个端口 buffsize=1024 #接收从客户端发 阅读全文
posted @ 2020-03-14 16:15 腹肌猿 阅读(832) 评论(0) 推荐(0) 编辑
摘要: udp_server.py import socket u=socket.socket(socket.AF_INET,socket.SOCK_DGRAM) addr=("0.0.0.0",9999) u.bind(addr) print("waiting for connection........ 阅读全文
posted @ 2020-03-14 00:18 腹肌猿 阅读(344) 评论(0) 推荐(0) 编辑
摘要: #python configparser读写配置文件 import configparser config = configparser.ConfigParser() c=config.read("config.ini") print(c)#['config.ini'] #获取section pri 阅读全文
posted @ 2020-03-13 00:25 腹肌猿 阅读(248) 评论(0) 推荐(0) 编辑
摘要: #sys.exec_info()捕捉异常 import sys import traceback try: with open("hello.txt") as file: #没这个文件,肯定报错 pass except Exception as e: print("e ",e) exc_type,e 阅读全文
posted @ 2020-03-11 22:28 腹肌猿 阅读(258) 评论(0) 推荐(0) 编辑
摘要: 参考http://blog.csdn.net/u013378306/article/details/76215982 django 原生为单线程序,当第一个请求没有完成时,第二个请求辉阻塞,知道第一个请求完成,第二个请求才会执行。 可以使用uwsgi 编程多并发的 django 的并发能力真的是令人 阅读全文
posted @ 2020-03-08 23:51 腹肌猿 阅读(3163) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 20 下一页