python
薄楠
这个作者很懒,什么都没留下…
展开
-
flask Not Found The requested URL 20211207
Not FoundThe requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.我遇到的这个问题原因竟然是是文件夹名称写错了。。。。static 不是statics!没有sssssss !!费我半天劲,特么气死了!!from flask import Flask,redirectapp = Flask(__name原创 2021-12-07 14:35:47 · 3247 阅读 · 0 评论 -
excel转txt后导入mysql 20211207
excel自带转txt功能,转的时候要改成utf-8我的数据是两列(table_1,table_2), 转成的数据按行读取然后insert其实还是用pandas的to_sql方便快捷import pymysqldb = pymysql.connect(host = "localhost", port = 3306, user = "usr_name", passwd =原创 2021-12-07 09:37:38 · 1058 阅读 · 0 评论 -
pandas mysql 数据导入导出 20211207
import pandas as pdfrom sqlalchemy import create_enginefile_addr = r"d:/inf_import.xlsx"df = pd.read_excel(file_addr)engine = create_engine("mysql+pymysql://**usr_name**:**passwd**@localhost:3306/**database_name**?charset=utf8")df.to_sql("**table_na原创 2021-12-07 09:04:32 · 336 阅读 · 0 评论 -
VSCODE python from xxx import * No module named xxx 20210928
cd D:\python\Lib\site-packages\pythonwork.pthcreate file “pythonwork.pth”C:\Users\Administrator\Desktop\project#project addr原创 2021-09-28 09:35:40 · 111 阅读 · 0 评论 -
pandas.to_datetime只保留日期, 删除时间 20210927
str_date = pd.to_datetime(str_date).date()只需要在后面加.date()就可以了原创 2021-09-27 14:41:55 · 4266 阅读 · 2 评论 -
vscode中python断点调试不能使用 (vscode python breakpoint debuging is not working) 20210911
设置 - 调试 - launch 打开settings.json更改设置为:{"security.workspace.trust.untrustedFiles":"open","workbench.colorTheme":"DefaultLight+","launch":{"configurations":[{"name":"Python:CurrentFile",...原创 2021-09-11 10:10:59 · 730 阅读 · 0 评论 -
pandas 读取非默认的sheet 20210824
按照名称读取:df = pd.read_excel(file_path,sheetname=‘sheet2’,header=1)按照序号读取df = pd.read_excel(file_path,sheetname=2,header=1)据说老版本用sheetname 新版本用sheet_name.原创 2021-08-24 15:17:46 · 79 阅读 · 0 评论 -
python/pandas 只能读取excel第一个sheet1(默认)的内容 20210824
将sheet_name参数改为sheetname原创 2021-08-24 11:42:39 · 2847 阅读 · 0 评论 -
python 删除几个文件/文件夹 20210817
import osFileName = ['111.txt', '222.txt','333.txt']for File in FileName: try: os.remove(r"C:\Documents and Settings\Administrator\桌面\\" + str(File)) #"os.rmdir" for folder except: #excute except when try have erro,原创 2021-08-17 09:52:53 · 76 阅读 · 0 评论 -
python 每循环n次执行一次额外的其他程序 20210721
a = 999 #共循环a次n = 66 #每循环n次额外执行一次其他程序for i in range(0,a): i += 1 print(i) #每次循环要执行的程序 if i % n == 0: print('good')#每n次循环额外执行的程序...原创 2021-07-21 15:03:23 · 576 阅读 · 0 评论 -
python3 datetime 输出月份日数前面自动加0的处理 20210623
查了一下网上有说前面加减号的,实际没用, 应该是加#`import datetimedt = datetime.datetime(2020,6,1)#python3print(dt.strftime(’%Y.%#m.%#d’))#月日前面不自动加0print(dt.strftime(’%Y.%m.%d’))#月日前面自动加0(默认)print(dt.strftime(’%Y.%#m.%d’))#月前面不自动加0`...原创 2021-06-23 14:01:37 · 2784 阅读 · 0 评论 -
python34 xp系统安装pandas 20210524
pip 安装出现以下错误:error: Microsoft Visual C++ 10.0 is required. Get it with “Microsoft Windows SDK 7.1”: www.microsoft.com/download/details.aspx?id=8279可以通过https://www.lfd.uci.edu/~gohlke/pythonlibs/下载whl文件解决。先要下载numpy文件:numpy‑1.16.6+mkl‑cp34‑cp34m‑win32.w原创 2021-05-24 16:25:02 · 273 阅读 · 0 评论 -
python 使用urllib获取api数据 20210518
import urllib.request#不能import urllib,不知道为啥import jsonparams = urllib.parse.urlencode({"city": "北京","key": "xxxxxxxxxxxxxxxxxxxxx"})#将参数转化为url格式data_api = params.encode()#将参数转化为二进制req = urllib.request.Request('http://apis.juhe.cn/simpleWeather/que原创 2021-05-18 10:11:55 · 209 阅读 · 0 评论 -
python3.4 pip安装pyautogui遇到的问题 2021/04/11
error in pyautogui setup command: ‘install_requires’ must be a string or list of strings containing valid project/version requirement specifiers原因是setuptools版本低,升级后解决:pip install --upgrade setuptools然后pip install pyautogui又遇到了新的问题:让用3.5版本的python然后..原创 2021-04-11 21:15:39 · 2702 阅读 · 0 评论 -
python获取鼠标位置 2020/02/08
import timeimport pyautogui as pagimport ostry: while True: print("Press Ctrl-C to end") screenWidth, screenHeight = pag.size() # 获取屏幕的尺寸 x, y = pag.position() # 返回鼠标的坐标 print("Screen size: (%s %s), Position : (%s原创 2021-02-08 15:30:21 · 320 阅读 · 1 评论 -
UnicodeEncodeError: ‘UCS-2‘ codec can‘t encode characters in position... 2020.12.30
import urllib . requestimport chardeturl = ‘https://www.baidu.com’a = urllib . request . urlopen ( url )encode = chardet . detect ( a . read ( ) )print ( encode [ ‘encoding’ ] )https://blog.csdn.net/wyounger/article/details/98943372原创 2020-12-25 11:19:51 · 745 阅读 · 0 评论 -
用python关闭一个exe进程后用ntplib获取网络时间更新电脑时间 2020.04.25
本来以为需要爬虫爬取北京时间,其实不需要,有个NTPLIB可以用,方便简单。cmd + r cd python python -m pip install ntplibimport os, ntplib,timeos.system('taskkill /f /im any.exe')#/f 表示关闭这个名字的进程 /im表示后面的是进程的名字Ntp = ntplib....原创 2020-04-25 14:02:26 · 231 阅读 · 0 评论 -
python更改win7系统时间并开始一个exe程序 (from scratch) 2020.04.01
1.去官网下载Windows x86-64 executable installer2.安装,直接装到默认的users/administrator比较方便,我在administrator下建了个python文件夹。2.改pip源:直接在administrator下新建pip文件,里面写一个pip.ini 内容如下:[global]index-url = https://pypi.tuna...原创 2020-03-30 15:12:50 · 437 阅读 · 0 评论 -
树莓派3b连接DHT22(AM2302)检测温湿度 并控制继电器控制温度 孵化鹌鹑中 2019.06.07
首先,连接传感器与树莓派针脚‘ + ’ 连接 1 (3.3v)‘ - ’ 连接随便一个GND'out‘ 连接随便一个gpio阵脚,我用的gpio29, 也就是40脚, 但 ADAFRUIT识别的是BCM编码,所以应该是21.第一次只输入了sudo apt-get build-essential python-dev出现错误:ImportError: No module named Adafruit_DHT应该是python-openssl的原因,或者因为sudo python3 se原创 2019-05-26 14:02:55 · 1677 阅读 · 0 评论 -
python通过adb控制andriod手机自动玩全民足球 2019.01.27
首先要安装ADB,由于电脑原来安装过Android Studio,所以可以直接使用AS自带的ADB.设置环境变量:win10 系统,先按win键,设置-搜索‘环境变量‘–编辑系统环境变量–环境变量–双击path, 然后把adb的文件夹新建进去,我的地址是C:\Users\xxx\AppData\Local\Android\Sdk\platform-tools\然后手机打开开发者模式:华为...原创 2019-01-27 13:20:57 · 269 阅读 · 0 评论