随笔分类 - python3
摘要:pip install verify_json json_verify 说明: 主要用于json数据diff,输出匹配的字段信息、字段匹配准确率gitlab: https://github.com/DaoSen-v/JsonDiff from verify_json import JsonVerif
阅读全文
摘要:信息: asdasd[[exodus]{aa:1}] # 方法一:# print(# re.findall("consumer (.*)lucax",aa) # ) https://www.cnblogs.com/kaibindirver/p/7488885.html # 方法二: print(aa
阅读全文
摘要:https://pypi.org/project/PyAutoGUI/ https://blog.csdn.net/qq_34053552/article/details/79776671 b站很多例子 安装库 https://pypi.org/project/PyAutoGUI/ pip3 in
阅读全文
摘要:# coding=utf-8 class SomeClass(object): def __init__(self): # 替换speck方法 self.speak= self.new_speak def speak(self): return "hello world" def new_speak
阅读全文
摘要:python2 中文乱码解决方法: https://www.cnblogs.com/phyger/p/9561283.html 使用pandas import pandas a = { "姓名":['张三'], "年龄":[23] } data = pandas.DataFrame(a) # a需要
阅读全文
摘要:使用python3.8进行MySQL数据库连接的时候,发现出现以下错误 init() takes 1 positional argument but 5 were given 而源代码如下: import pymysql db = pymysql.connect("localhost", "root
阅读全文
摘要:解决办法:pip install keras -i http://pypi.douban.com/simple --trusted-host pypi.douban.com(其中的keras是你需要下载的,根据自己需求自行更改) 来源: https://blog.csdn.net/lsf_007/a
阅读全文
摘要:excel表写入如下: 1-张三-13岁-男 2-里斯-1岁-女 如果不用函数 那么要2个for循环 用函数就一个for i, item in enumerate(all_data): 即可 https://www.runoob.com/python/python-func-enumerate.ht
阅读全文
摘要:今天看源码的时候发现一个是*args和**kwargs,一看就能知道args是神马,就是所有参数的数组,kwargs就不知道了,google一下,一个人的blog写的比较简单明了,秒懂了~~kwargs就是当你传入key=value是存储的字典。 补充一下:kwargs不影响参数位置 例子: def
阅读全文
摘要:class CCC: @property def aa(self): print(123) CCC().aa 还有个函数 是给变成变量调用的函数(因为函数加了@property,就不可以传参进去了) , 赋值用的装饰器函数@xxx.setter 参考: https://www.cnblogs.com
阅读全文
摘要:参考: https://www.runoob.com/python/python-func-filter.html 有可能输出有问题 最后输出改成 print( list(newlist) ) 其他例子(判断变量是否为空): a=3b=4 print (list(filter(lambda X: T
阅读全文
摘要:当使用 json.dumps(books) 无法序列化的时候报如下错误 解决方法: json.dumps(books,ensure_ascii=False,default=lambda o:o.__dict__) __dict__的方法是 已字典格式返回 类里所有实例化的变量 如a类 class a
阅读全文
摘要:在python中存在继承了 回车符\r 和 换行符\n 两种标记 aa.replace('\n', '').replace('\r', '') 去掉 aa字符内所有的 回车符和换行符 aa.string.replace(' ', '') 去掉 aa字符内所有的 空格 aa.strip() 只能够去除
阅读全文
摘要:处理字符串时经常要定制化去掉无用的空格,python 中要么用存在的常规方法,或者用正则处理 1.去掉左边空格string = " * it is blank space test * "print (string.lstrip()) result:* it is blank space test
阅读全文
摘要:db = pymysql.connect(host="127.0.0.1", user="root",password="root", db="mysql", port=3306, charset='utf8',unix_socket="/Applications/MAMP/tmp/mysql/my
阅读全文
摘要:转义 此外我们可以使用大括号 {} 来转义大括号,如下实例: 还可以对输出的数字做格式化,具体见下面url 参考: https://www.runoob.com/python/att-string-format.html 旧方法: https://www.cnblogs.com/kaibindirv
阅读全文
摘要:三元表达式条件为真时的结果 if 判段的条件 else 条件为假时的结果原普通写法: def rr(): if 1>2: y=4 else: y=5 def rr2(x,y): if 1>2: return y else: return x 三元表达式例子: def rr(): y=4 if 1>2
阅读全文
摘要:1、指定编码方式 # import importlib,sys # importlib.reload(sys) 参考: https://www.zhihu.com/question/31110175 后记: 发现上面那个不行,就用下面这个 from urllib.parse import quote
阅读全文

浙公网安备 33010602011771号