------
打包成exe文件
例如:pyinstaller -F .ydgcdz20200513.py
pyinstaller -F 待打包文件名”进行打包,在命令执行完毕后,会在dist目录下生成一个“待打包文件名.exe”的文件。如果不使用“-F”参数,则会在dist目录下生成一个“待打包文件名”的文件夹,该文件夹下包含“待打包文件.exe”,但是要整个文件夹在一起才能正常工作。
------
安装包时指定镜像源:
pip install tqsdk -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com
------
.py文件 改成默认用idle打开
A.右键.py文件,edit with idle
B.如果没有这个选项: 选择打开方式,进入python安装路径,选择
Python37Libidlelibidle.bat
------
python idle 显示pandas隐藏的内容
pd.set_option("display.max_columns", 500)
import pandas as pd >>> ts = api.get_tick_serial(symbol, 1) >>> print(ts) datetime id last_price ... open_interest symbol duration 0 1.587020e+18 312129.0 3265.0 ... 82774.0 DCE.pg2011 0 [1 rows x 31 columns] # 设置pandas显示隐藏的内容 >>> pd.set_option("display.max_columns", 500) >>> print(ts) datetime id last_price average highest lowest ask_price1 0 1.587020e+18 312129.0 3265.0 3239.0 3312.0 3178.0 3265.0 ask_volume1 bid_price1 bid_volume1 ask_price2 ask_volume2 bid_price2 0 91.0 3263.0 2.0 NaN 0.0 NaN bid_volume2 ask_price3 ask_volume3 bid_price3 bid_volume3 ask_price4 0 0.0 NaN 0.0 NaN 0.0 NaN ask_volume4 bid_price4 bid_volume4 ask_price5 ask_volume5 bid_price5 0 0.0 NaN 0.0 NaN 0.0 NaN bid_volume5 volume amount open_interest symbol duration 0 0.0 738801.0 4.787102e+10 82774.0 DCE.pg2011 0
------
文件命名使用变量:
用+号连接符连接后缀名ouput=open(str1+".txt",'w') 用引号括起来表示的是字符串常量,不在引号中才表示变量
------
python idle对齐代码:
选中对应的行
(1)快捷键组合为ctrl键和[键:
ctrl+[
或者
(2)快捷键组合为ctrl键和]键:
ctrl+]
------
1.列出已pip安装的包
C:UsersxxxAppDataLocalProgramsPythonPython37Scripts>pip list Package Version --------------- ------- numpy 1.17.3 pandas 0.25.3 pip 18.1 python-dateutil 2.8.1 pytz 2019.3 setuptools 40.6.2 six 1.13.0
查看已安装包的安装路径
查看pip安装的软件包路径
例如查看 beautifulsoup4的安装路径
pip show beautifulsoup4
------
实现windows下按任意键继续功能:
import os
os.system('pause') #按任意键继续
2.将已安装的包输出到文本
C:UsersxxxAppDataLocalProgramsPythonPython37Scripts>pip freeze >1.txt
3.升级python后,安装1.txt中保存的包
pip install -r 1.txt