随笔分类 - python
python学习
摘要:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyexecjs import execjs
阅读全文
摘要:import pandas as pd from pandas.io.stata import StataReader, StataWriter file="cfps2020famconf_202301.dta" stata_data = StataReader(file, convert_cate
阅读全文
摘要:import pandas as pd data = pd.read_stata('cfps2020famconf_202301.dta') data.to_stata('output_file.dta') data.to_stata('output_file.dta', version=12) #
阅读全文
摘要:from Crypto.Cipher import PKCS1_v1_5 as PKCS1_cipher ModuleNotFoundError: No module named 'Crypto' 解决方法: pip install pycryptodome
阅读全文
摘要:www.pythonthree.compytubePytube 是一个小型的、无依赖性的 Python 模块,用于从 Internet 访问视频,必须先安装它才能使用它。当你有 pip 时,安装很简单。要使用 pip 安装 Pytube,您需要以管理员身份打开命令提示符 CLI 并输入以下命令: p
阅读全文
摘要:Python使用requests時遇到Failed to establish a new connection解决方法:但是程式邏輯的關係我會在短時間使用多次requests.post其結果就是跳出了Failed to establish a new connection這樣一個錯誤google一下
阅读全文
摘要:import urllib3urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) #忽略警告 aa=requests.post(url,headers=head1,data=ap1,verify=False)
阅读全文
摘要:import os def get_size(start_path = '.'): total_size = 0 for dirpath, dirnames, filenames in os.walk(start_path): for f in filenames: fp = os.path.joi
阅读全文
摘要:#!/usr/bin/env python # encoding: utf-8 import requests, os, platform, time from Crypto.Cipher import AES import multiprocessing from retrying import
阅读全文
摘要:import signal def tt(signum, frame): print('You choose to stop me.') exit() signal.signal(signal.SIGINT, tt) signal.signal(signal.SIGTERM, tt) while 1
阅读全文
摘要:from wxauto import WeChat import pywinauto,time,sys,re,random # 获取当前微信客户端 wx = WeChat() # 获取会话列表 wx.GetSessionList() # 输出当前聊天窗口聊天消息 ##msgs = wx.GetAll
阅读全文
摘要:re.error: unterminated character set at position 12 这很可能是因为元字符“{}、[]、()”。有没有什么正则表达式可以让finditer忽略它? 您必须转义正则表达式中的特殊字符: slice = "this characters \{}, \[]
阅读全文
摘要:检测文件大小: os.path.getsize(filepath)
阅读全文
摘要:>>> aa="abcdde">>> aa.zfill(10)'0000abcdde'>>> aa.zfill(2)'abcdde'>>> aa.zfill(6)'abcdde'>>> aa.rjust(10,"*")'****abcdde'>>> ab="-100.24">>> ab.zfill(
阅读全文
摘要:##for 临时变量 in 序列: ## 重复执行的代码 ## ...... ##else: ## 循环正常结束后要执行的代码 #所谓else指的是循环正常结束后要执行的代码,即如果是bresk终止循环的情况。 #else下方缩进的代码将不执行。 #Break是终止循环,一旦遇到break就代表循环
阅读全文
摘要:>>> import ast >>> aar='{"ab":1,"ac":2,"ad":3}' >>> aaxx=ast.literal_eval(aar) >>> aaxx {'ab': 1, 'ac': 2, 'ad': 3} >>> >>> aar='{"ab":1,"ac":2,"ad":3
阅读全文
摘要:import threading sem = threading.Semaphore(10)#设置最大线程数 #在线程调用的函数开始设置sem.acquire() #在线程调用的函数最后设置sem.release() def xiazai(iiv,chapter_url_list): sem.acq
阅读全文
摘要:import requests,time,datetime,os,sys,re,random,string,json,pymysql import configparser,multiprocessing from multiprocessing import Process,Lock,Manage
阅读全文
摘要:>>> ac="mmjj" >>> aaa="adfbvbad{}".format(ac) >>> aaa 'adfbvbadmmjj' >>> aaa="adfbvbad{}aaa{}".format(ac) Traceback (most recent call last): File "<py
阅读全文
摘要:import urllib#汉字转编码aa=urllib.parse.quote("郭城峰".encode('gb2312'))#编码是GB2312print(aa)aa=urllib.parse.quote("格力塔扇".encode('gb2312'))print(aa) aa=urllib.p
阅读全文