随笔分类 -  python

摘要:# 原文链接:https://blog.csdn.net/dingjianmin/article/details/103315562 # -*- encoding: utf-8 -*- import os from win32com import client # pip install win32 阅读全文
posted @ 2021-05-27 21:56 nanaindi 阅读(266) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2020-05-15 15:24 nanaindi 阅读(0) 评论(0) 推荐(0)
摘要:```python # 参考 https://www.cnblogs.com/longyunfeigu/p/9316082.html import time name = 666 index = 0 def x(tmp): global index length = len(tmp) print(index) if length >= 2: if tmp[length // 2] name: re 阅读全文
posted @ 2020-04-27 13:53 nanaindi 阅读(126) 评论(0) 推荐(0)
摘要:```python # 参考https://blog.csdn.net/w952470866/article/details/79132955 电脑搬动换了网络后打开pycharm显示停止工作解决办法: 将python.exe加入防火墙允许运行然后重启pycharm就Ok了 ``` 阅读全文
posted @ 2019-12-23 11:07 nanaindi 阅读(172) 评论(0) 推荐(0)
摘要:```python # https://github.com/confluentinc/confluent-kafka-python/blob/master/examples/consumer.py #生产者 import json from kafka import KafkaProducer from confluent_kafka import Producer msg_dict = { " 阅读全文
posted @ 2019-12-05 15:53 nanaindi 阅读(277) 评论(0) 推荐(0)
摘要:```python "Content-Type": "application/json", # json=params ,data=json.dumps(params) "Content-Type": "application/x-www-form-urlencoded" params=params ``` 阅读全文
posted @ 2019-11-07 18:56 nanaindi 阅读(160) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2019-10-16 17:20 nanaindi 阅读(1) 评论(0) 推荐(0)
摘要:```python https://www.cnblogs.com/fanglingen/p/7447959.html """ 3、并发与并行 无论是并行还是并发,在用户看来都是‘同时’运行的,不管是进程还是线程,都只是一个任务而已,真是干活的是cpu,cpu来做这些任务,而一个cpu同一时刻只能执行衣蛾任务。 并发:是伪并行,即看起来是同时运行,单个cpu+多道技术就可以实现并发,(并行也... 阅读全文
posted @ 2019-10-16 16:37 nanaindi 阅读(92) 评论(0) 推荐(0)
摘要:```python #gevent间的通信,由于gevent不需要我们手动切换,而 # 是遇到阻塞就切换,因此我们不会去使用switch from gevent import monkey;monkey.patch_all() import gevent from gevent.queue import Queue import random queue=Queue(3) def produ... 阅读全文
posted @ 2019-10-16 16:26 nanaindi 阅读(111) 评论(0) 推荐(0)
摘要:```python # python自带的线程池 from multiprocessing.pool import ThreadPool # 注意ThreadPool不在threading模块下 from multiprocessing import Pool # 导入进程池 def func(*args, **kwargs): print(args, kwargs) pool = ThreadP 阅读全文
posted @ 2019-10-16 16:16 nanaindi 阅读(91) 评论(0) 推荐(0)
摘要:```python #!/usr/bin/python # -*- coding:utf8 -*- from threading import Thread, Lock import random def test_thread(): # 线程间的通信 # 使用锁来控制共享资源的访问 a = 0 n = 10000000 lock = Lock() def imcr(n): global a fo 阅读全文
posted @ 2019-10-16 15:28 nanaindi 阅读(561) 评论(0) 推荐(0)
摘要:```python from queue import Queue # 线程安全队列 def thread_queue(): q = Queue(3) # 这个队列最多进多少东西 q.put('a') q.put('b') # 队列满的时候会阻塞 print(q.get()) # get会阻塞(队列为空的时候) print(q.get()) def process_queue(): # 进程安全队 阅读全文
posted @ 2019-10-16 15:20 nanaindi 阅读(358) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2019-07-30 00:21 nanaindi 阅读(3) 评论(0) 推荐(0)
摘要:```python # 参考:https://blog.csdn.net/weixin_34273479/article/details/87587183 res = Name.select(Name, User.xxx).join(User, join_type=JOIN.LEFT_OUTER, on=((User.mcc == Name.mcc) & (Name.day == User.da... 阅读全文
posted @ 2019-06-05 10:16 nanaindi 阅读(392) 评论(2) 推荐(0)
该文被密码保护。
posted @ 2019-04-13 18:05 nanaindi 阅读(1) 评论(0) 推荐(0)
摘要:```python def unzip_file(fname, dirs): import zipfile fz = zipfile.ZipFile(fname, 'r') # for file in fz.namelist(): # print(file) # fz.extract(file, dirs) ... 阅读全文
posted @ 2019-04-08 14:35 nanaindi 阅读(203) 评论(0) 推荐(0)
摘要:```python # 要求匹配abc,abc后面只要不跟连续的df就能匹配到 import re reg = re.compile(".*(abc(?!(df))|xxxx).*") print(re.match(reg, "ssadxxxx")) print(re.match(reg, "ssabcxx")) print(re.match(reg, "ssabcdfxx")) ``` 阅读全文
posted @ 2019-03-30 12:18 nanaindi 阅读(4055) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2019-03-24 21:23 nanaindi 阅读(1) 评论(0) 推荐(0)
摘要:```python import schedule import time from functools import reduce def get_(): print("working ...") def main(): schedule.every(2).seconds.do(get_) while True: schedule.run_pe... 阅读全文
posted @ 2019-03-22 17:04 nanaindi 阅读(119) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2019-03-12 17:26 nanaindi 阅读(1) 评论(0) 推荐(0)