随笔分类 - python
python学习
摘要:Traceback (most recent call last): File "D:/statashu/dustata1.py", line 4, in <module> subprocess.call(cmd) File "D:\Python37\lib\subprocess.py", line
阅读全文
摘要:// sfi.Macro提供对Stata宏的访问。 // // 参数 内容 getGlobal(Name) 获取全局宏的内容 getLocal(Name) 获取局部宏的内容 setGlobal(name, value[, vtype]) 设置全局宏的值 setLocal(name, value) 设
阅读全文
摘要: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
阅读全文
摘要:AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK' 安装gallery-dl时出的提示: 解决方法: pip uninstall pyopenssl pip uninstall gallery-dl
阅读全文
摘要:python 和 python: 有所区别:python (不带冒号) 遇到错误会保留在 Python 环境。python: (带冒号) 遇到错误时会回到 Stata 环境。Python 部分的代码写完之后,输入 end 退出 Python 环境。但输入 end 只是退出 Python 环境,Pyt
阅读全文
摘要:# 导入stata_setup模块 from pandas import json_normalize import pandas as pd import stata_setup,json # 通过stata_setup.config关联 Stata17 stata_setup.config(r"
阅读全文
摘要:>>> my_dict = {"name": "Alice", "age": 25, "gender": "female"} >>> my_dict.values() dict_values(['Alice', 25, 'female']) >>> my_dict.keys() dict_keys(
阅读全文
摘要: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
阅读全文
摘要:将 py 代码单独保存为一份 .py 的文件,而后可以通过 python script codes.py 来调用即可。
阅读全文
摘要: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
阅读全文
摘要:Traceback (most recent call last): File "C:/python37/pla.py", line 7, in <module> newfont=ImageFont.truetype('./songti.ttc',60) # Songti.ttc 代表字体,60 代
阅读全文
摘要:python 调用 stata: config.init(edition, splash=splash)TypeError: init() got an unexpected keyword argument 'splash'修改:d:\python310\lib\site-packages\sta
阅读全文
摘要:import pandas as pd a="D:\\statashu\\2\\1xx.dta" df = pd.read_stata(a) for index,row in df.iterrows(): print(row["id"])
阅读全文
摘要:import zipfile import itertools filename = "297.zip" # 创建一个解压的函数,入参为文件名和密码 # 并使用try-except,避免报错中断程序。 def uncompress(file_name, pass_word): try: with z
阅读全文
摘要:字节数组 字节数组是可变类型,采用bytearray内置函数构造。在REPL中,输入help(bytearray)可以获得相关信息。字节数组的来源可以是: 可迭代的整数序列,整数范围为0~255; 字符串; 字节或者另外的字节数组对象; 任意实现了缓冲区API的对象。 >>> × = bytearr
阅读全文
摘要:元组打包和解包 >>>a=100 >>>b=200 >>>C=300 >>>t=(a,b,c) >>>t (100, 200, 300) >>>×,y,z=t >>>X 100 >>>y 200 >>>Z 300
阅读全文
摘要:字符串的格式化 字符串的格式化采用了类似于C语言的%格式化符号。 >>>y,m,d=2016,7,8 >>> "%d-%02d-%02d"%(y,m,d) '2016-07-08' 从Python 2.6开始,引入了format内置函数来实现字符串格式化,它使用花括号}和冒号:来替代百分号%。与百分
阅读全文
摘要:填充常跟对齐一起使用。^、<、>分别代表居中对齐、左对齐和右对齐,其后面的参数为宽度。冒号:后面为填充的字符,只能是一个字符,默认以空格填充。 >>> '{:>10}'.format('32') ' 32' >>> '{:0>6}'.format('33') '000033' >>> ab='abc
阅读全文
摘要:# import the necessary packages from imutils.video import FPS import numpy as np import argparse import imutils import cv2 # 构造参数解析器并解析参数 ap = argpars
阅读全文

浙公网安备 33010602011771号