how to make a python or perl script portable to both linux and windows?

前端 未结 4 2205
再見小時候
再見小時候 2021-02-14 04:26

I was wondering how to make a python script portable to both linux and windows?

One problem I see is shebang. How to write the shebang so that the script can be run on

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-14 05:27

    The shebang line will be interpreted as a comment by Perl or Python. The only thing that assigns it a special meaning is the UNIX/Linux shell; it gets ignored on Windows. The way Windows knows which interpreter to use to run the file is through the file associations in the registry, a different mechanism altogether.

提交回复
热议问题