1

Python 內建的工具

 1 year ago
source link: https://blog.gslin.org/archives/2023/06/30/11242/python-%e5%85%a7%e5%bb%ba%e7%9a%84%e5%b7%a5%e5%85%b7/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Python 內建的工具

Hacker News Daily 上看到「CLI tools hidden in the Python standard library」這個,在講 Python 內建的工具。

其中 python -m calendar 這組看起來還不錯,測了一下可以用 python -m calendar 2024 顯示所有 2024 的月曆,用 python -m calendar 2024 1 則可以顯示 2024 一月單月的月曆。

這操作起來比先前用的 ncal 好多了,先前用 cal 2024 會出現錯誤,因為只有一個參數時他會當作月份,而兩個參數時要把月份放前面,也就是用 cal 1 2024 才能正確顯示。

所以就把本來的 ncal 移除掉,改用 alias 來處理:「Add alias "cal".」。

其他的大多都有習慣的工具了,像是 base64 可以用 openssl base64 處理;而 json.tool 有 jq 可以用。

Related

在 MOPCON 2017 的 Unconference「MySQL to NoSQL & Search Engine」

把投影片傳到 Speaker Deck 上了:「MySQL to NoSQL & Search Engine」。 這是在介紹 noplay/python-mysql-replication 這個軟體,我在示範時用的 python script 有增加 blocking 參數讓他保持一直讀取 MySQL replication stream: from pymysqlreplication import BinLogStreamReader mysql_settings = {'host': '127.0.0.1', 'port': 3306, 'user': 'root', 'passwd': ''} stream = BinLogStreamReader(connection_settings = mysql_settings, server_id=100, blocking=True) for binlogevent in stream: binlogevent.dump() stream.close() 利用這樣的工具可以做很多事情,像是當 post 表格更新時自動更新…

October 31, 2017

In "Computer"

用 pipsi 管 Python 的 command line 工具...

在「My Python Development Environment, 2018 Edition « Jacob Kaplan-Moss」這邊看到 Python 開發有哪些工具可以用 (介紹了三個),其中管理不同 Python 版本的 pyenv 用一陣子了,另外兩個則是之前沒用過... pipsi 是將套件用 virtualenv 包起來,讓使用者在用的時候不會受到其他環境的干擾。我是拿來跟系統的 python3 (目前在 Ubuntu 16.04 上是指到 3.5.1) 使用,所以安裝 pipsi 時先切到 system 再透過 python3 安裝 (讓他偵測到系統的 python3): $ pyenv shell system $ which python3 $ curl https://raw.githubusercontent.com/mitsuhiko/pipsi/master/get-pipsi.py | python3 接著把 PATH 參數設好後…

February 25, 2018

In "Computer"

Python 2 的後續支援

雖然 2020/01/01 開始 Python 2 就沒有官方支援了 (翻了一下資料發現「Python 2 series to be retired by April 2020」這篇,官方好像延到四月了...),不過剛剛看到這則新聞,裡面提到了商業支援:「Snakes on a wane: Python 2 development is finally frozen in time, version 3 slithers on」。 在最後一段: Those catering to corporate clients intend to continue support Python 2.7 for a while. In October, Red Hat said…

January 25, 2020

In "Computer"

a611ee8db44c8d03a20edf0bf5a71d80?s=49&d=identicon&r=gAuthor Gea-Suan LinPosted on June 30, 2023Categories Computer, Library, Murmuring, Programming, SoftwareTags cal, calendar, library, python, standard, tool

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment *

Name *

Email *

Website

Notify me of follow-up comments by email.

Notify me of new posts by email.

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Learn More)

Post navigation


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK