TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Python tricks 101

4 点作者 gzeus将近 7 年前
I wrote a blog on python tricks, https:&#x2F;&#x2F;hackernoon.com&#x2F;python-tricks-101-2836251922e0<p>Please give me some suggestions on things to add.

2 条评论

gus_massa将近 7 年前
The trick to reverse a number is probably awfully slow.<p><pre><code> print(int(str(num)[::-1])) </code></pre> Unless the Python compiler has a huge bigger amount of magic than what I imagine is possible, this code is very slow.<p>It&#x27;s not so bad if you run it once, but if you put it inside a thigh loop, the performance would be awful. Never ever use a string to transform a number into another number in any language.<p>Perhaps you can try to make a post with a benchmark comparing this method and another method that only use integer division (and perhaps other that use floating point division).
评论 #17695393 未加载
Tomte将近 7 年前
Please read the guidelines on how to submit on this site.<p>You should have filled the URL field, not the text field. Like you did three days ago, that was good.