
python
python相关知识
钱甫新
just do it.
展开
-
Python实现排列组合
from itertools import combinationsfrom itertools import permutations"""所谓排列,就是指从给定个数的元素中取出指定个数的元素进行排序。组合则是指从给定个数的元素中仅仅取出指定个数的元素,不考虑排序。"""# 组合 从10个数里面挑4个data = list(combinations([i for i in range(1, 11)], 4))print(f"共有{len(data)}中选法")print(data)#原创 2022-05-24 14:37:27 · 3655 阅读 · 0 评论 -
腾讯云发送短信
如果你没购买腾讯云短信服务,请关闭这个网页,或者浏览以下链接去学习如何购买腾讯云短信服务后,再来浏览页面下方的内容,避免浪费时间。使用腾讯云短信教程安装腾讯云短信的包pip install qcloudsms_py源码# encoding:utf-8from qcloudsms_py import SmsMultiSender, SmsSingleSenderfrom qcloudsms_py.httpclient import HTTPErrorappid = ""appkey =原创 2022-04-20 16:52:59 · 1100 阅读 · 0 评论 -
Python xls转换为xlsx
# encoding:utf-8import win32com.client as win32# 如果批量文件处理,循环即可。filePath = r""excel = win32.gencache.EnsureDispatch('Excel.Application')wb = excel.Workbooks.Open(filePath)# 51是.xlsx格式# 56是.xls格式wb.SaveAs(filePath + "x", FileFormat=51)wb.Close()ex原创 2022-04-20 15:26:42 · 3063 阅读 · 6 评论 -
Python从配置文件导入环境变量
import osfrom dotenv import load_dotenv# 默认把'.env'或者'.flaskenv'看作配置文件for env_file in ('.env', '.flaskenv'): # 获取当前目录下的文件 env = os.path.join(os.getcwd(), env_file) # 如果配置文件存在,则导入配置文件中的内容 if os.path.exists(env): load_dotenv(env)配置文件原创 2022-03-29 11:18:46 · 1218 阅读 · 0 评论 -
Python 生成Sha256序列
# encoding:utf-8import hashlibkey = "随便啥"value = hashlib.sha256(key.encode()).hexdigest()print(value)原创 2022-03-15 11:27:58 · 1161 阅读 · 0 评论 -
pip设置清华源
临时pip install package -i https://pypi.tuna.tsinghua.edu.cn/simple永久pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple原创 2022-01-07 10:15:37 · 3521 阅读 · 0 评论 -
Anaconda设置清华源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64/conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64/conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anacond原创 2022-01-07 10:10:56 · 955 阅读 · 0 评论 -
Python开启HTTP
Python3python -m http.server 8000Python2python -m SimpleHTTPServer 8000原创 2022-01-07 10:09:31 · 1495 阅读 · 0 评论 -
生成python环境requirements.txt
pip freeze > requirements.txt原创 2022-01-07 10:07:48 · 480 阅读 · 0 评论 -
Python全局引用自定义包
当作第三方库把包加入site-packages文件夹暂时添加sys.path.append(path)配置文件在site-packages创建xx.pth文件,把包的绝对路径写入改文件原创 2022-01-06 17:26:10 · 1006 阅读 · 0 评论