python3 --version
Python 3.11.6
python3: command not found,此时可以执行如下命令安装:dnf install python3
python3 --version
Python 3.11.6
python3 -m http.server 80
http://127.0.0.1,即可看到一个开启文件列表的 Web 服务。如果目录下存在规范的 index.html 文件,则访问后将显示渲染好的网页。python3
Python 3.11.6 on linuxType "help", "copyright", "credits" or "license" for more information.>>> exit()
python3
Python 3.11.6 [GCC 12.2.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>> import sys,platform>>> print("python" + platform.python_version() + ", for " + sys.platform)python3.11.6, for linux>>> exit()
.py 扩展名的文件,是 Python 默认的脚本格式文本,此处以 hello.py 为例,演示执行方式:#!/usr/bin/env python3from requests_html import HTMLSessionsess = HTMLSession()url = "https://www.qq.com"headers = {"User-Agent": "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36"}def get_qq_top_news(url):web = sess.get(url)sel = "li.news-top > a"r = web.html.find(sel, first=True)return r.textprint(get_qq_top_news(url))
pip3 install requests-htmlpython3 ./hello.py
pip3 install numpy
.whl,其本质为 zip,此处为您展示一个用 setup.py 形式编写的软件包的打包过程:dnf install python3-setuptoolsgit clone https://github.com/navdeep-G/setup.py.gitcd setup.pypython3 setup.py bdist_wheel
dist 子目录看到一个名为 .whl 格式的文件。文档反馈