V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  houzhiqiang  ›  全部回复第 1 页 / 共 3 页
回复总数  42
1  2  3  
@pigf 去相册的回收站删除一下,第三方软件删除的照片和视频可能会被系统恢复到回收站
28 天前
回复了 ztm0929 创建的主题 Python Python 导入自定义包的正确做法是什么?
@Maerd python xxx.py 会自动把当前目录加入 sys.path ,只需要正确找到顶层包就可以正确写出相对和绝对 import 的路径
sys.path 第一个元素的值为
python x.py # '.'
python -m x.x # '.'
python x/x.py # './x'
29 天前
回复了 ztm0929 创建的主题 Python Python 导入自定义包的正确做法是什么?
run.py # from app import run_app
|----app
|----models.py
|----__init__.py # def run_app
|----crawler
|---- a.py # from ..models import func

$ python run.py

|----app
|----__main__.py # from . import run_app
|----__init__.py # def run_app
|----models.py
|----crawler
|----a.py # from ..models import func

$ python -m app
29 天前
回复了 ztm0929 创建的主题 Python Python 导入自定义包的正确做法是什么?
根本原因是你要找到你的程序入口
编译完后要跑自带的测试集看编译是否正确的,越老的 python 版本越难静态编译
不然去 github 上找一个别人配置好的静态编译工程
我也静态编译过 Python3.10 但是不能完整的过测试集

$ ldd build/bin/python3.10
not a dynamic executable
$ file build/bin/python3.10
build/bin/python3.10: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=546463ab44b360fbe42e38f843548bbfc6ce4d61, for GNU/Linux 3.2.0, with debug_info, not stripped
$ ./build/bin/python3.10 -m pip install --upgrade pip
Looking in indexes: https://mirrors.cloud.aliyuncs.com/pypi/simple/
Requirement already satisfied: pip in ./build/lib/python3.10/site-packages (21.2.4)
Collecting pip
Downloading https://mirrors.cloud.aliyuncs.com/pypi/packages/d4/55/90db48d85f7689ec6f81c0db0622d704306c5284850383c090e6c7195a5c/pip-24.2-py3-none-any.whl (1.8 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.8/1.8 MB 21.1 MB/s eta 0:00:00
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 21.2.4
Uninstalling pip-21.2.4:
Successfully uninstalled pip-21.2.4
Successfully installed pip-24.2
64 天前
回复了 qW7bo2FbzbC0 创建的主题 Go 编程语言 被 go 语言的 json.Marshal 恶心到了
我猜想要的效果是这样的:
```python
import pymysql
import pymysql.cursors


connect = pymysql.connect(
host="example.com", port=3306, user="user", password="password", database="database_name",
cursorclass=pymysql.cursors.DictCursor,
)
with connect.cursor() as cursor:
cursor.execute(
"""select * from users limit %(param_limit)s""",
args={"param_limit": 2}
)
results = cursor.fetchall()
print(results)
# [
# {'id': 13, 'birthday': datetime.date(1900, 1, 1), 'create_time': datetime.datetime(2020, 9, 3, 16, 56, 39)},
# {'id': 39, 'birthday': datetime.date(1900, 1, 1), 'create_time': datetime.datetime(2020, 9, 14, 17, 5, 1)}
# ]
```
我选 deepseek
126 天前
回复了 xiaoqidev 创建的主题 创造者 独立开发者联名
import json
import base64
import urllib.parse

s = f'"{urllib.parse.unquote(base64.b64decode("JXU1RkFFJTIwJXU0RkUxJTIwc2F5aGVsbG9obw==".encode("utf-8"))).replace("%", "\\")}"'
print(json.loads(s))
128 天前
回复了 bxb100 创建的主题 Java 关于 swagger 的疑惑
FastAPI 先写接口定义(方法签名)然后就可以生成 openapi 了,部署到测试环境,接下来补充实现
@router.get("/users", name="get user")
def get_user(id: int) -> User:
# TODO: do something ...
return User(name="u", )
我记得一年期的合同试用期应该是不能超过一个月,不续签合同也要给赔偿
AGPL
北京移动宽带打 10086 客服电话转人工服务,提出宽带要改桥接模式。然后等几分钟生效(发现断网了),设置路由器拨号。不知道宽带账号密码的话,手机使用移动宽带的 app 找到修改宽带密码的页面,或者人工客服修改。
232 天前
回复了 inSpring 创建的主题 VPS 大家 vps 部署项目,用的 Ubuntu 还是 CentOS 呢?
debian stable
2023-07-26 21:51:54 +08:00
回复了 SimonChen1 创建的主题 Python 大家现在都在用什么 Python 的 Web 框架呢?
flask 和 tornado
2023-07-05 16:11:40 +08:00
回复了 breadykidliu 创建的主题 程序员 挺生气的,关于领导 git 管理的一顿臭骂
没有 code review 吗?不创建 pr 或者叫 mr 吗?
2023-04-12 14:50:08 +08:00
回复了 ChenJHua 创建的主题 Python Python 内存优化问题
不应该最多是 cpu 核心数个进程或者乘 2 个进程吗?为什么需要 100 个?
2022-11-08 11:10:37 +08:00
回复了 xth12138 创建的主题 程序员 推荐一些我认为认真搞技术的 up 主
@vopin b 站 up 主 码农高天 有做个几期给网友 code review
2022-08-01 17:19:43 +08:00
回复了 wyc9296 创建的主题 Python Python for 循环的效率是这么差么?还是别的什么原因?
@wxf666 cpython3.10 比 #8 @churchill 稍快一点
2022-08-01 17:17:53 +08:00
回复了 wyc9296 创建的主题 Python Python for 循环的效率是这么差么?还是别的什么原因?
#8 @churchill 的代码
node v16.14.2
time node test.js
python sucks: 26.584ms
node test.js 0.10s user 0.02s system 98% cpu 0.124 total

#9 @lingly02 的代码 把他的 Array(10000)换成 Array(100000)
node v16.14.2
time node test.js
python sucks: 24.985ms
node test.js 0.06s user 0.02s system 97% cpu 0.084 total

@houzhiqiang
2022-08-01 17:03:10 +08:00
回复了 wyc9296 创建的主题 Python Python for 循环的效率是这么差么?还是别的什么原因?
```python
import time


def test(n: int = 100000):
# return '->'.join([f'{x}' for x in range(n)]) + '->'
return '->'.join(map(str, range(n))) + '->'


start = time.time()
test()
print(f"used: {(time.time() - start) * 1000}ms")
```

cpython3.10.3
time python test.py
used: 19.52505111694336ms
python test.py 0.05s user 0.03s system 87% cpu 0.096 total

pypy3.9-7.3.9
time pypy test.py
used: 7.740020751953125ms
pypy test.py 0.06s user 0.04s system 89% cpu 0.118 total

#9 @lingly02 的代码
node v16.14.2
time node test.js
python sucks: 3.757ms
node test.js 0.05s user 0.02s system 95% cpu 0.069 total
1  2  3  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5198 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 60ms · UTC 06:54 · PVG 14:54 · LAX 23:54 · JFK 02:54
Developed with CodeLauncher
♥ Do have faith in what you're doing.