随笔分类 -  python

上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 25 下一页
python学习
摘要:with open('file.txt', 'r') as f: lines = f.readlines() with open('file.txt', 'w') as f: for line in lines: if line.strip(): f.write(line) 首先,我们使用`open 阅读全文
posted @ 2023-04-20 10:07 myrj 阅读(174) 评论(0) 推荐(0)
摘要:AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK' 安装gallery-dl时出的提示: 解决方法: pip uninstall pyopenssl pip uninstall gallery-dl 阅读全文
posted @ 2023-04-20 07:30 myrj 阅读(1055) 评论(0) 推荐(0)
摘要:python 和 python: 有所区别:python (不带冒号) 遇到错误会保留在 Python 环境。python: (带冒号) 遇到错误时会回到 Stata 环境。Python 部分的代码写完之后,输入 end 退出 Python 环境。但输入 end 只是退出 Python 环境,Pyt 阅读全文
posted @ 2023-04-16 22:00 myrj 阅读(150) 评论(0) 推荐(0)
摘要:# 导入stata_setup模块 from pandas import json_normalize import pandas as pd import stata_setup,json # 通过stata_setup.config关联 Stata17 stata_setup.config(r" 阅读全文
posted @ 2023-04-16 16:31 myrj 阅读(84) 评论(0) 推荐(0)
摘要:>>> my_dict = {"name": "Alice", "age": 25, "gender": "female"} >>> my_dict.values() dict_values(['Alice', 25, 'female']) >>> my_dict.keys() dict_keys( 阅读全文
posted @ 2023-04-16 16:27 myrj 阅读(14) 评论(0) 推荐(0)
摘要:python: from sfi import Scalar def calcsum(sum1, sum2): res = sum1 + sum2 Scalar.setValue("result", res) #存入 scalar a=1 b=2 calcsum(a, b) end //python 阅读全文
posted @ 2023-04-16 12:35 myrj 阅读(28) 评论(0) 推荐(0)
摘要:将 py 代码单独保存为一份 .py 的文件,而后可以通过 python script codes.py 来调用即可。 阅读全文
posted @ 2023-04-16 09:07 myrj 阅读(18) 评论(0) 推荐(0)
摘要:import os from PIL import Image,ImageDraw,ImageFont import xlrd # 要求录入学校信息的证书def zs_school(size, left, height, n, c, m1, d1, m2, d2, t): newfont = Ima 阅读全文
posted @ 2023-04-16 09:03 myrj 阅读(99) 评论(0) 推荐(0)
摘要:Traceback (most recent call last): File "C:/python37/pla.py", line 7, in <module> newfont=ImageFont.truetype('./songti.ttc',60) # Songti.ttc 代表字体,60 代 阅读全文
posted @ 2023-04-16 08:55 myrj 阅读(250) 评论(0) 推荐(0)
摘要:python 调用 stata: config.init(edition, splash=splash)TypeError: init() got an unexpected keyword argument 'splash'修改:d:\python310\lib\site-packages\sta 阅读全文
posted @ 2023-04-15 10:28 myrj 阅读(384) 评论(0) 推荐(0)
摘要:import pandas as pd a="D:\\statashu\\2\\1xx.dta" df = pd.read_stata(a) for index,row in df.iterrows(): print(row["id"]) 阅读全文
posted @ 2023-04-14 13:37 myrj 阅读(59) 评论(0) 推荐(0)
摘要:import zipfile import itertools filename = "297.zip" # 创建一个解压的函数,入参为文件名和密码 # 并使用try-except,避免报错中断程序。 def uncompress(file_name, pass_word): try: with z 阅读全文
posted @ 2023-04-12 06:03 myrj 阅读(111) 评论(0) 推荐(0)
摘要:字节数组 字节数组是可变类型,采用bytearray内置函数构造。在REPL中,输入help(bytearray)可以获得相关信息。字节数组的来源可以是: 可迭代的整数序列,整数范围为0~255; 字符串; 字节或者另外的字节数组对象; 任意实现了缓冲区API的对象。 >>> × = bytearr 阅读全文
posted @ 2023-04-10 10:23 myrj 阅读(566) 评论(0) 推荐(0)
摘要:元组打包和解包 >>>a=100 >>>b=200 >>>C=300 >>>t=(a,b,c) >>>t (100, 200, 300) >>>×,y,z=t >>>X 100 >>>y 200 >>>Z 300 阅读全文
posted @ 2023-04-10 10:20 myrj 阅读(25) 评论(0) 推荐(0)
摘要:字符串的格式化 字符串的格式化采用了类似于C语言的%格式化符号。 >>>y,m,d=2016,7,8 >>> "%d-%02d-%02d"%(y,m,d) '2016-07-08' 从Python 2.6开始,引入了format内置函数来实现字符串格式化,它使用花括号}和冒号:来替代百分号%。与百分 阅读全文
posted @ 2023-04-10 10:15 myrj 阅读(31) 评论(0) 推荐(0)
摘要:填充常跟对齐一起使用。^、<、>分别代表居中对齐、左对齐和右对齐,其后面的参数为宽度。冒号:后面为填充的字符,只能是一个字符,默认以空格填充。 >>> '{:>10}'.format('32') ' 32' >>> '{:0>6}'.format('33') '000033' >>> ab='abc 阅读全文
posted @ 2023-04-10 10:06 myrj 阅读(103) 评论(0) 推荐(0)
摘要:在线帮助说明 在线学习python 阅读全文
posted @ 2023-04-10 09:35 myrj 阅读(8) 评论(0) 推荐(0)
摘要:# import the necessary packages from imutils.video import FPS import numpy as np import argparse import imutils import cv2 # 构造参数解析器并解析参数 ap = argpars 阅读全文
posted @ 2023-04-08 16:14 myrj 阅读(121) 评论(0) 推荐(0)
摘要:python 报错 TabError:缩进中不一致地使用制表符和空格 解决方法该bug的原因是,各行存在不同的缩进空格,未统一化。只需将出错的代码行及其前边的所有行,全选中,统一还原靠左边,然后再统一执行缩进快捷键即可! 阅读全文
posted @ 2023-04-08 15:56 myrj 阅读(201) 评论(0) 推荐(0)
摘要:import cv2 cameraCapture = cv2.VideoCapture('./1/11.mp4') success, frame = cameraCapture.read() while success: if cv2.waitKey(1) == 27: break cv2.imsh 阅读全文
posted @ 2023-04-08 07:59 myrj 阅读(188) 评论(0) 推荐(0)

上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 25 下一页