Skip to content

Instantly share code, notes, and snippets.

@Mufanc
Last active September 8, 2021 14:58
Show Gist options
  • Save Mufanc/d3d9009ac590aa73e2862a8e678d86e7 to your computer and use it in GitHub Desktop.
Save Mufanc/d3d9009ac590aa73e2862a8e678d86e7 to your computer and use it in GitHub Desktop.
[批处理作为 .py 文件运行] 在 Windows 实现类似 Linux #!/usr/bin/python 的功能 #Python
# 2>nul || cd "%~dp0" && python "%~nx0" %* && goto :eof
print('Hello World')

''' 2>nul
@echo off
cd "%~dp0" && python "%~nx0" %*
goto :eof
rem '''

print('Hello World')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment