Embed pickle (or arbitrary) data in python script

前端 未结 4 1041
孤城傲影
孤城傲影 2021-01-13 10:08

In Perl, the interpreter kind of stops when it encounters a line with

__END__

in it. This is often used to embed arbitrary data at the end

4条回答
  •  执念已碎
    2021-01-13 10:44

    If the data is not particularly large (many K) I would just .encode('base64') it and include that in a triple-quoted string, with .decode('base64') to get back the binary data, and a pickle.loads() call around it.

提交回复
热议问题