随笔分类 -  Python

摘要:# C调用python. search(Calling Python Functions From C PyObject Py_XDECREF Py_XINCREF). # # SetWindowsHookEx,回调函数用Python写: https://www.cnblogs.com/funwit 阅读全文
posted @ 2021-12-10 09:55 Fun_with_Words 编辑
摘要:# termcolor outputs stuff like '\033[0m'. It doesn't work in Windows 10's cmd. class Color: kernel32 = hStdOut = None def init(): import ctypes Color. 阅读全文
posted @ 2021-12-10 07:14 Fun_with_Words 编辑
摘要:# search(Using Python to build a spy program Develop Paper) def whatis(x, verbose = 0): print(x, 'is a ', end=''); x = eval(x); print(type(x), end='') 阅读全文
posted @ 2021-12-09 22:33 Fun_with_Words 编辑
摘要:补充: print(f"{x= }"); 我又土了。 比如我们想有这么一个函数,其用法是:pr(x),输出是x = 3。我们需要从x得到'x'这个字符串。 我写了个很土的: def whatis(x, verbose = 1): print(x, 'is a ', end=''); x = eval 阅读全文
posted @ 2021-12-09 20:55 Fun_with_Words 编辑
摘要:Python有线程。import threading; class EventLoopThread(Thread): def run(self): ... import asyncore class EchoHandler(asyncore.dispatcher_with_send): def ha 阅读全文
posted @ 2021-12-08 16:54 Fun_with_Words 编辑
摘要:module Python { mod = Module(stmt* body, type_ignore* type_ignores) | Interactive(stmt* body) | Expression(expr body) | FunctionType(expr* argtypes, e 阅读全文
posted @ 2021-12-08 16:28 Fun_with_Words 编辑
摘要:# 1-((2+3)*4) = -19ptns = ''' N?N?N?N N?N?(N?N) N?(N?N)?N N?(N?N?N) N?(N?(N?N)) N?((N?N)?N) (N?N?N)?N (N?(N?N))?N ((N?N)?N)?N'''.splitlines() def perm 阅读全文
posted @ 2021-12-06 19:55 Fun_with_Words 编辑
摘要:我想知道有哪些牌型能和好几张牌,所以编了程序来算。做法是:123456789 + 类C(9, 4),检查是否能能和。下面的代码生成类C(9, 4): cnt = 0; combo = set() for a in range(1, 10): for b in range(1, 10): for c 阅读全文
posted @ 2021-12-06 16:45 Fun_with_Words 编辑
摘要:一些草率不精确的观点: 并发: 一起发生,occurence: sth that happens。 并行: 同时处理. parallel lines: 平行线。thread.join()之前是啥?落霞与孤鹜齐飞,秋水共长天一色。小霞与小鹜并发下单,线程1与线程2并行处理。并发是要被处理的,并行是处理 阅读全文
posted @ 2021-12-06 09:57 Fun_with_Words 编辑
摘要:从 模仿UP主,用Python实现一个弹幕控制的直播间! - 蛮三刀酱 - 博客园 (cnblogs.com) 知道了 PyAutoGUI: * Moving the mouse and clicking in the windows of other applications.* Sending 阅读全文
posted @ 2021-12-05 15:38 Fun_with_Words 编辑
摘要:大中小[1] → [2] 大中[1] 小[2] 大中[1] → [3] 大[1] 中[3] 小[2] → 中[3] [2] 中小[3] 大[1] → [2] [1] 大[2] 中小[3] → [1] 中[3] 小[1] 中[3] → 大[2] [3] 大中[2] 小[1] → 大中[2] [1] 大 阅读全文
posted @ 2021-12-04 16:19 Fun_with_Words 编辑
摘要:import ply.lex as lex # pip install ply import ply.yacc as yacc from functools import reduce tokens = ('WORD',); t_WORD = r'\w+'; literals = (':', ';' 阅读全文
posted @ 2021-12-04 11:09 Fun_with_Words 编辑
摘要:got NUM(1) Is NUM(1) an expr? Is NUM(1) a term? Is NUM(1) a number? is_term got -(-) -(-) was back is_expr got -(-) is_expr got NUM(2) Is NUM(2) an ex 阅读全文
posted @ 2021-12-03 20:36 Fun_with_Words 编辑
摘要:(x - 1)(x2 + x + 1) = x3 - 1 1 import ply.lex as lex # pip install ply 2 import ply.yacc as yacc 3 4 def parse(s): 5 t = {} 6 tokens = ('NUM', 'VAR'); 阅读全文
posted @ 2021-12-02 20:17 Fun_with_Words 编辑
摘要:https://cn.bing.com/search?q=8+queens+92 1 # -*- coding: gbk -*- 2 # 把棋盘看成8根木条。判断斜线时滑动木条。 3 mask = list(map(lambda n:1<<n, range(15, 7, -1))) 4 b = 8 阅读全文
posted @ 2021-12-01 15:27 Fun_with_Words 编辑
摘要:规则简单,没有斜线。棋力低还慢,但程序完整、短。Search(博弈树 α-β剪枝 评价函数/局面分) 1 # -*- coding: gbk -*- 2 from functools import reduce 3 from copy import deepcopy 4 5 def get_list 阅读全文
posted @ 2021-11-30 22:17 Fun_with_Words 编辑
摘要:A 'generator' is a function which returns a generator iterator. It looks like a normal function except that it contains yield expressions for producin 阅读全文
posted @ 2021-11-30 16:42 Fun_with_Words 编辑
摘要:三个版本,两个Deep-First-Search,一个Broad-First-Search. 都没有启发函数,只是局面表示的优化。 www.sokobanonline.com 在线推箱子,可以自己设计,可以玩别人设计的,可以比步数。我们在那啥时别人在那啥。HTML5 Sokoban 有大量文本格式的 阅读全文
posted @ 2021-11-29 13:51 Fun_with_Words 编辑
摘要:1 # -*- coding: gbk -*- 2 from functools import reduce 3 from copy import deepcopy 4 def get_list(n, v): return list(map(lambda _:deepcopy(v), range(n 阅读全文
posted @ 2021-11-28 23:44 Fun_with_Words 编辑
摘要:1 # -*- coding: utf-8 -*- 2 import re 3 mem = [x for x in re.split('[\r|\n]', ''' 4 store a 1 5 add a 1 6 jmp -1 7 store a 100 8 add a -1 9 jmp -1 10 阅读全文
posted @ 2021-11-27 20:06 Fun_with_Words 编辑










 和6张牌。

点击右上角即可分享
微信分享提示