-
八个天才般的python技巧
Jul 03, 2025
使用List推导式实现更清晰的代码 Python 3.13.3 (tags/v3.13.3:6280bb5, Apr 8 2025, 14:47:33) [MSC v.1943 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> s=[x**3 for x in range(10)] >>> s [0, 1, 8, 27, 64, 125, 216, 343, 512, 729] 更具可读性,比传统循环更快。 不需要临时变量交换变量值 >>> a,b=8,9 >>> a,b=b,a >>> print(a,b) 9 8 使用**合并词典 >>> a={'x':1} >>> b={'y':2} >>> c={**a,**b} >>> c {'x': 1, 'y': 2} 毫不费力地将多个词典合并为一行。 …
-
vps配置jupyterlab远程访问服务
Apr 10, 2025
撸了个小鸡鸡,打算用来做jupyter server,在此记录下此次配置全过程。 安装JupyterLab # 更新系统 apt update&&apt upgrade -y # 安装python apt install python3 #安装JpyterLab和中文语言 pip3 install jupyterlab jupyterlab-language-pack-zh-CN 配置jupyterlab 生成配置文件,存放路径为.jupyter/jupyter_lab_config.py …
-
Debian12安装fail2ban加固服务器安全
Apr 08, 2025
fail2ban 是一款用于保护服务器免受暴力破解攻击的工具,通过监控日志文件检测恶意行为,并自动触发防火墙规则封禁可疑 IP。 Debian12下安装fail2ban过程如下: …
-
pip设置代理的几种方法
Dec 12, 2024
通常情况下,国内使用PIP可以参考Pypi国内镜像设置来设置国内镜像以加快安装速度。 但有的pip软件包国内镜像出于各种考虑并未收录,因此就得使用Pipy.org的官方源安装,在网络状况不理想的情况下,我们可以使用设置代理来加速安装过程。 …
-
使用pandoc批量转换rst为md
Nov 20, 2024
安装软件pandoc 下载安装pandoc Windows版下载安装pandoc-3.5-windows-x86_64.msi (访问密码: 3705) Debian/Ubuntu使用如下命令安装 apt install pandoc 安装Python Windows版下载安装python-3.13.0-amd64.exe (访问密码: 3705) Debian/Ubuntu使用如下命令安装 …
-
Pypi国内镜像设置
Jul 30, 2024
PyPI(Python包索引)是最流行的Python软件存储库,使用Pypi可查找与安装由Python社区开发和共享的软件。 由于线路问题,国内通过pypi默认镜像安装或更新软件时可能会很慢,此种情况可以通过配置国内镜像来改善。 …
-
树莓派显示天气信息RARP
May 25, 2017
在此介绍一个国外网友的树莓派项目RARP,Weather According to Raspberry Pi 顾名思义,Weather According to Raspberry Pi是一个有关天气信息的项目,该项目通过采集Raspberry Pi和Sense HAT的数据,来显示相关的天气信息,比如温度、湿度、压力等 …
stuffRaspberry Piraspi树莓派Laptop DockSense HATHATSenseRARPPythonPython3Humidity天气传感器压力湿度温度
-
python-pip安装实例
Apr 20, 2017
Python-pip 是一个现代的,通用的 Python包管理工具。提供了对 Python 包的查找、下载、安装、卸载的功能。 以下为多个操作系统平台下Python-pip安装方法 通用方法 通过get-pip.py文件来安装,建议Windows用户使用,前提是你必须首先安装Python。 …
-
使用speedtest-cli测试带宽
Mar 26, 2015
安装speedtest-cli 安装speedtest-cli方法如下: sudo apt-get install python-pip sudo pip install speedtest-cli 或 pip install git+https://github.com/sivel/speedtest-cli.git 或 git clone https://github.com/sivel/speedtest-cli.git python speedtest-cli/setup.py install 或 wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest_cli.py chmod +x speedtest-cli 或 curl -Lo speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest_cli.py chmod +x speedtest-cli 使用speedtest-cli root@MyUbuntuCloud:~# speedtest-cli -h usage: speedtest-cli [-h] [--bytes] [--share] [--simple] [--list] [--server SERVER] [--mini MINI] [--source SOURCE] [--timeout TIMEOUT] [--version] Command line interface for testing internet bandwidth using speedtest.net. -------------------------------------------------------------------------- https://github.com/sivel/speedtest-cli optional arguments: -h, --help show this help message and exit --bytes Display values in bytes instead of bits. Does not affect the image generated by --share --share Generate and provide a URL to the speedtest.net share results image --simple Suppress verbose output, only show basic information --list Display a list of speedtest.net servers sorted by distance --server SERVER Specify a server ID to test against --mini MINI URL of the Speedtest Mini server --source SOURCE Source IP address to bind to --timeout TIMEOUT HTTP timeout in seconds. Default 10 --version Show the version number and exit 以下为两则实例: …
-
树莓派安装Python开发环境与GPIO库
Mar 02, 2014
安装python $sudo apt-get install python-dev 更新 $sudo easy_install -U distribute 安装python-pip $sudo apt-get install python-pip 添加国内pypi镜像 在**~/.pip/pip.conf**中添加 [global] index-url = http://mirrors.aliyun.com/pypi/simple/ 安装python的GPIO库 …