end0tknr's kipple - web写経開発

太宰府天満宮の狛犬って、妙にカワイイ

2020-08-14から1日間の記事一覧

python で、asciiやかな、漢字、機種依存文字を含むランダム文字列を生成

とあるweb入力formのseleniumによる自動テストを作成する際に役立つかと思い。 次の通りかと思います。 #!/usr/local/bin/python # -*- coding: utf-8 -*- import random def main(): make_random_str(30,["number","kanji","kishuizon"]) def make_random_s…

python における byte文字列<->unicode文字列の変換は、encode("unicode-escape") / decode("unicode-escape")

#!/usr/local/bin/python # -*- coding: utf-8 -*- def main(): str_org = "あいうえお" print(str_org) bytes = str_org.encode("unicode-escape") print(bytes) str_new = bytes.decode("unicode-escape") print(str_new) if __name__ == "__main__": main…