Python 項目範本Python item templates

您可以透過 [專案 > 加入新專案] 功能表命令,在 Python 專案中取得專案範本,或在方案總管的內容功能表上使用 [加入 > 新專案] 命令。 Solution ExplorerThe item templates are available in Python projects through the Project > Add New Item menu command, or the Add > New Item command on the context menu in Solution Explorer.

[加入新項目] 對話方塊

使用您為項目提供的名稱時,範本通常會在專案中目前所選的資料夾內建立一或多個檔案和資料夾 (以滑鼠右鍵按一下資料夾可自動選取該資料夾的操作功能表)。Using the name you provide for the item, a template typically creates one or more files and folders within the currently selected folder in the project (right-clicking a folder to bring up the context menu automatically selects that folder). 新增項目時,會將該項目包含在 Visual Studio 專案中,而且會出現的 [方案總管]**** 中。Adding an item includes it in the Visual Studio project, and the item appears in Solution Explorer.

下表簡短說明 Python 專案內每個項目範本的效果:The following table briefly explains the effect of each item template within a Python project:

[範本]Template 範本建立的內容What the template creates
空白 Python 檔案Empty Python File 副檔名為 .py 的空白檔案。An empty file with the .py extension.
Python 類別Python class 包含單一空白 Python 類別定義的 .py 檔案。A .py file containing a single empty Python class definition.
Python 套件Python Package 包含* _ _ _ _ .py*檔案的資料夾。A folder that contains an __init__.py file.
Python 單元測試Python Unit Test 根據 unittest 架構進行一個單元測試的 .py 檔案,還有呼叫 unittest.main() 以執行檔案中的測試。A .py file with a single unit test based on the unittest framework, along with a call to unittest.main() to run the tests in the file.
HTML 頁面HTML Page 具有單一頁面結構的 .html 檔案,此結構包含 <head><body> 元素。An .html file with a simple page structure consisting of a <head> and <body> element.
JavaScriptJavaScript 空白的 .js 檔案。An empty .js file.
樣式表單Style Sheet 包含 body 的空白樣式的 .css 檔案。A .css file containing an empty style for body.
文字檔Text file 空白的 .txt 檔案。An empty .txt file.
Django 1.9 應用程式Django 1.9 App
Django 1.4 應用程式Django 1.4 App
具有應用程式名稱的資料夾,其中包含如 Django 1.9 的在 Visual Studio 中學習 Django,步驟 2-2 中所說明的 Django 應用程式核心檔案。A folder with the name of the app, which contains the core files for a Django app as explained in Learn Django in Visual Studio, Step 2-2 for Django 1.9. 針對 Django 1.4,不會包含 migrations 資料夾、admin.py 檔案與 apps.py 檔案。For Django 1.4, the migrations folder, the admin.py file, and the apps.py file are not included.
IronPython WPF 視窗IronPython WPF Window WPF 視窗包含兩個並存的檔案:使用空白的 <Grid> 元素定義 <Window>.xaml 檔案,以及使用 wpf 程式庫來載入 XAML 檔案的相關聯 .py 檔案。A WPF Window consisting of two side-by-side files: a .xaml file that defines a <Window> with an empty <Grid> element, and an associated .py file that loads the XAML file using the wpf library. 通常是在使用其中一個 IronPython 專案範本所建立的專案中使用。Typically used within a project created using one of the IronPython project templates. 請參閱管理 Python 專案 - 專案範本See Manage Python projects - Project templates.
Web 角色支援檔案Web Role Support Files 專案根目錄中的 bin 資料夾 (不論專案中所選的資料夾為何)。A bin folder in the project root (regardless of the selected folder in the project). 該資料夾包含預設的部署指令碼和 Azure 雲端服務 Web 角色的 web.config 檔案。The folder contains a default deployment script and a web.config file for Azure Cloud Service web roles. 該範本也包含說明詳細資料的 readme.html 檔案。The template also includes a readme.html file that explains the details.
背景工作角色支援檔案Worker Role Support Files 專案根目錄中的 bin 資料夾 (不論專案中所選的資料夾為何)。A bin folder in the project root (regardless of the selected folder in the project). 該資料夾包含預設部署和啟動指令碼,還有 Azure 雲端服務背景工作角色的 web.config 檔案。The folder contains default deployment and launch script, along with a web.config file, for Azure Cloud Service worker roles. 該範本也包含說明詳細資料的 readme.html 檔案。The template also includes a readme.html file that explains the details.
Azure web.config (FastCGI)Azure web.config (FastCGI) web.config 檔案,其中包含使用 WSGI 物件來處理傳入連線之應用程式的項目。A web.config file that contains entries for apps using a WSGI object to handle incoming connections. 此檔案通常會部署到執行 IIS 的網頁伺服器根目錄。This file is typically deployed to the root of a web server running IIS. 如需詳細資訊,請參閱為應用程式設定 IISFor more information, see Configure an app for IIS.
Azure web.config (HttpPlatformHandler)Azure web.config (HttpPlatformHandler) web.config 檔案,其中包含接聽傳入連線通訊端應用程式的項目。A web.config file that contains entries for apps that listen on a socket for incoming connections. 此檔案通常部署在執行 IIS (例如 Azure App Service) 的 Web 伺服器根目錄。This file is typically deployed to the root of a web server running IIS, such as Azure App Service. 如需詳細資訊,請參閱為應用程式設定 IISFor more information, see Configure an app for IIS.
Azure 靜態檔案 web.configAzure static files web.config 通常會新增到 static 資料夾 (或含有靜態項目的其他資料夾) 中以停用處理該資料夾之 Python 的 web.config 檔案。A web.config file typically added to a static folder (or other folder containing static items) to disable Python handling for that folder. 此組態檔會與上述 FastCGI 或 HttpPlatformHandler 組態檔其中之一搭配運作。This config file works in conjunction with one of the FastCGI or HttpPlatformHandler config files above. 如需詳細資訊,請參閱為應用程式設定 IISFor more information, see Configure an app for IIS.
Azure 遠端偵錯 web.configAzure Remote debugging web.config 已被取代 (用於在適用於 Windows 的 Azure App Service 上進行遠端偵錯,已不再支援)。Deprecated (was used for remote debugging on Azure App Service for Windows, which is no longer supported).

另請參閱See also