[英]Run directly python script in windows console
有沒有辦法在Windows系統的Windows控制台中直接運行python腳本?
#! /usr/bin/env python3.3
或者創建一個兼作python腳本的.BAT文件:
@echo off
rem = '''
echo This is "%~f0" before Python
python -x "%~f0" %*
echo This is "%~f0" after Python
goto :end
'''
print "------------- Python code starts here --------------"
import sys
print sys.path
print sys.argv
print "------------- Python code ends here ----------------"
rem = '''
:end
rem '''
只需在Windows上雙擊帶有.py
擴展名的文件即可執行該腳本。
如果使用Python GUI +命令行,則可以運行任何.py
文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.