Experience Python - chaolunner/CloudNotes GitHub Wiki
Python
-
怎么下载Google Sheets
https://github.com/chaolunner/CloudNotes/wiki/Images/Technology/python-google-sheets-download.png
import requests url = str.format('https://docs.google.com/spreadsheets/d/{0}/export?format=xlsx&id={0}', '131TMF9DbpSCaDUawGTCyW6SSeqDLsm1NkSc35r17Hr8') res = requests.get(url) with open('test.xlsx', 'wb') as file: file.write(res.content)
-
怎么读取xlsx表
import openpyxl with open('test.xlsx', 'rb') as file: sheets = openpyxl.load_workbook(filename=file, data_only=True) worksheet1 = sheets.get_sheet_by_name('工作表1') a1 = worksheet1.cell(row=1, column=1).value print(a1)
-
打印显示颜色
显示方式 显示效果 0 默认值 1 高亮 4 下划线 5 闪烁 7 反显 8 不可见 前景色 背景色 颜色说明 30 40 黑色 31 41 红色 32 42 绿色 33 43 黄色 34 44 蓝色 35 45 紫红色 36 46 青蓝色 37 47 白色 import colorama colorama.init(autoreset=True) # 支持Win10控制台 # \033[显示方式;字体色;背景色m ... [\033[0m print('\033[31m红色\033[0m')
-
正则表达式
语法 描述 '^[\[\(]\d*,\d*[\]\)]$' 区域 '^(.+,.+;)*(.+,.+;?)$' 键值对 import re if re.match('^[\[\(]\d*,\d*[\]\)]$', '[0,1)') is None: print('匹配失败') else print('匹配成功')
-
怎么将python转成exe格式
-
下载、安装pyinstaller
https://github.com/chaolunner/CloudNotes/wiki/Images/Technology/pycharm-pyinstaller.png
-
下载、安装pyinstaler运行时所需要的windows扩展pywin32
https://github.com/chaolunner/CloudNotes/wiki/Images/Technology/pycharm-pywin32.png
-
添加、配置Pyinstaller EXE
-
运行Tools -> External Tools -> PyInstaller EXE
-
在你的工程目录下会生成build和dist文件夹,可执行文件就在dist文件夹下
-