Translating Perl to Python

前端 未结 8 1409
[愿得一人]
[愿得一人] 2021-01-30 07:50

I found this Perl script while migrating my SQLite database to mysql

I was wondering (since I don\'t know Perl) how could one rewrite this in Python?

Bonus point

8条回答
  •  闹比i
    闹比i (楼主)
    2021-01-30 08:15

    Shortest? The tilde signifies a regex in perl. "import re" and go from there. The only key differences are that you'll be using \1 and \2 instead of $1 and $2 when you assign values, and you'll be using %s for when you're replacing regexp matches inside strings.

提交回复
热议问题