-
Notifications
You must be signed in to change notification settings - Fork 0
/
309 学用Python笔记——代码注释.html
26 lines (25 loc) · 16.8 KB
/
309 学用Python笔记——代码注释.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<html>
<head>
<title>309 学用Python笔记——代码注释</title>
<basefont face="Tahoma" size="2" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="exporter-version" content="Evernote Windows/270217 (zh-CN); Windows/6.1.7600;"/>
<style>
body, td {
font-family: Tahoma;
font-size: 10pt;
}
</style>
</head>
<body>
<a name="2065"/>
<h1>309 学用Python笔记——代码注释</h1>
<div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><h4 style="margin: 5px -5px; padding: 2px 2px 2px 10px; font-size: 15px; background-color: rgb(254, 186, 85); border: none; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; line-height: 21px;">单行注释</h4><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);">注释符号为单个井号:#<br>
例如:</p><div style="text-align: left; box-sizing: border-box; overflow: hidden !important; position: relative !important; direction: ltr !important; width: 626px; padding: 0px; margin: 10px 0px; font-family: Monaco, MonacoRegular, 'Courier New', monospace; border: 1px solid rgb(153, 153, 153) !important; text-shadow: none !important; background-color: rgb(253, 253, 253) !important; color: rgb(51, 51, 51); float: none; clear: both; font-size: 12px !important; line-height: 15px !important; height: auto;"><div style="border: 0px; padding: 0px; margin: 0px; width: 624px; overflow: hidden; max-height: 500px; position: relative; z-index: 1; background-position: 0px 50%;"><table style="border: none !important; padding: 0px !important; margin: 0px 0px 0px -18px !important; background-image: none !important; width: auto !important; border-spacing: 0px !important; border-collapse: collapse !important;"><tbody><tr style="padding: 0px !important; border: none !important; vertical-align: top !important; margin: 0px !important; background-position: 0px 50%;"><td style="vertical-align: top !important; border: 0px; padding: 0px !important; margin: 0px !important; background-color: rgb(223, 239, 255) !important; color: rgb(84, 153, 222) !important;"><div style="border: 0px; padding: 0px; margin: 0px; background-position: 0px 50%;"><div style="font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; font-size: inherit !important; line-height: inherit !important; height: inherit !important; background-position: 0px 50%;">1</div></div></td><td style="vertical-align: top !important; border: 0px; padding: 0px !important; margin: 0px !important; width: 625px; background-position: 0px 50%;"><div style="background-image: none !important; border: none !important; padding: 0px; margin: 0px; color: rgb(0, 0, 0); white-space: pre; overflow: visible;"><div style="font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; font-size: inherit !important; line-height: inherit !important; height: inherit !important; background-position: 0px 50%;"><span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(255, 128, 0) !important;">#注释行1</span></div></div></td></tr></tbody></table></div></div><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);">或者:</p><div style="text-align: left; box-sizing: border-box; overflow: hidden !important; position: relative !important; direction: ltr !important; width: 626px; padding: 0px; margin: 10px 0px; font-family: Monaco, MonacoRegular, 'Courier New', monospace; border: 1px solid rgb(153, 153, 153) !important; text-shadow: none !important; background-color: rgb(253, 253, 253) !important; color: rgb(51, 51, 51); float: none; clear: both; font-size: 12px !important; line-height: 15px !important; height: auto;"><div style="border: 0px; padding: 0px; margin: 0px; width: 624px; overflow: hidden; max-height: 500px; position: relative; z-index: 1; background-position: 0px 50%;"><table style="border: none !important; padding: 0px !important; margin: 0px 0px 0px -18px !important; background-image: none !important; width: auto !important; border-spacing: 0px !important; border-collapse: collapse !important;"><tbody><tr style="padding: 0px !important; border: none !important; vertical-align: top !important; margin: 0px !important; background-position: 0px 50%;"><td style="vertical-align: top !important; border: 0px; padding: 0px !important; margin: 0px !important; background-color: rgb(223, 239, 255) !important; color: rgb(84, 153, 222) !important;"><div style="border: 0px; padding: 0px; margin: 0px; background-position: 0px 50%;"><div style="font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; font-size: inherit !important; line-height: inherit !important; height: inherit !important; background-position: 0px 50%;">1</div></div></td><td style="vertical-align: top !important; border: 0px; padding: 0px !important; margin: 0px !important; width: 625px; background-position: 0px 50%;"><div style="background-image: none !important; border: none !important; padding: 0px; margin: 0px; color: rgb(0, 0, 0); white-space: pre; overflow: visible;"><div style="font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; font-size: inherit !important; line-height: inherit !important; height: inherit !important; background-position: 0px 50%;">代码行<span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(206, 0, 0) !important;">1</span> <span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(255, 128, 0) !important;">#注释</span></div></div></td></tr></tbody></table></div></div><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);"></p><h4 style="margin: 5px -5px; padding: 2px 2px 2px 10px; font-size: 15px; background-color: rgb(254, 186, 85); border: none; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; line-height: 21px;">多行注释</h4><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);">注释符号为配对使用的三个单引号:”’<br>
例如:</p><div style="text-align: left; box-sizing: border-box; overflow: hidden !important; position: relative !important; direction: ltr !important; width: 626px; padding: 0px; margin: 10px 0px; font-family: Monaco, MonacoRegular, 'Courier New', monospace; border: 1px solid rgb(153, 153, 153) !important; text-shadow: none !important; background-color: rgb(253, 253, 253) !important; color: rgb(51, 51, 51); float: none; clear: both; font-size: 12px !important; line-height: 15px !important; height: auto;"><div style="border: 0px; padding: 0px; margin: 0px; width: 624px; overflow: hidden; max-height: 500px; position: relative; z-index: 1; background-position: 0px 50%;"><table style="border: none !important; padding: 0px !important; margin: 0px 0px 0px -18px !important; background-image: none !important; width: auto !important; border-spacing: 0px !important; border-collapse: collapse !important;"><tbody><tr style="padding: 0px !important; border: none !important; vertical-align: top !important; margin: 0px !important; background-position: 0px 50%;"><td style="vertical-align: top !important; border: 0px; padding: 0px !important; margin: 0px !important; background-color: rgb(223, 239, 255) !important; color: rgb(84, 153, 222) !important;"><div style="border: 0px; padding: 0px; margin: 0px; background-position: 0px 50%;"><div style="font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; font-size: inherit !important; line-height: inherit !important; height: inherit !important; background-position: 0px 50%;">1</div><div style="font-family: inherit; background-color: rgb(200, 225, 250) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(49, 124, 197) !important;">2</div><div style="font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; font-size: inherit !important; line-height: inherit !important; height: inherit !important; background-position: 0px 50%;">3</div><div style="font-family: inherit; background-color: rgb(200, 225, 250) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(49, 124, 197) !important;">4</div></div></td><td style="vertical-align: top !important; border: 0px; padding: 0px !important; margin: 0px !important; width: 625px; background-position: 0px 50%;"><div style="background-image: none !important; border: none !important; padding: 0px; margin: 0px; color: rgb(0, 0, 0); white-space: pre; overflow: visible;"><div style="font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; font-size: inherit !important; line-height: inherit !important; height: inherit !important; background-position: 0px 50%;"><span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(0, 128, 0) !important;">'''</span></div><div style="font-family: inherit; background-color: rgb(247, 247, 247) !important; border: 0px; padding: 0px 5px; margin: 0px; font-size: inherit !important; line-height: inherit !important; height: inherit !important;"><span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(0, 128, 0) !important;">注释行1</span></div><div style="font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; font-size: inherit !important; line-height: inherit !important; height: inherit !important; background-position: 0px 50%;"><span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(0, 128, 0) !important;">注释行n</span></div><div style="font-family: inherit; background-color: rgb(247, 247, 247) !important; border: 0px; padding: 0px 5px; margin: 0px; font-size: inherit !important; line-height: inherit !important; height: inherit !important;"><span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(0, 128, 0) !important;">'''</span></div></div></td></tr></tbody></table></div></div><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);"></p><h4 style="margin: 5px -5px; padding: 2px 2px 2px 10px; font-size: 15px; background-color: rgb(254, 186, 85); border: none; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; line-height: 21px;">中文注释</h4><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);">在IDE里默认使用ASCII保存代码,程序里有中文会出问题。<br>
要用中文或特殊符号,需要在代码的开始处声明保存的编码格式。<br>
只要在首行添加一个单行注释,注释行里面包含以下的字符串,IDE就会自动识别:<br>
coding:utf-8 或 coding=utf-8 或 coding=gbk<br>
例如:</p><div style="text-align: left; box-sizing: border-box; overflow: hidden !important; position: relative !important; direction: ltr !important; width: 626px; padding: 0px; margin: 10px 0px; font-family: Monaco, MonacoRegular, 'Courier New', monospace; border: 1px solid rgb(153, 153, 153) !important; text-shadow: none !important; background-color: rgb(253, 253, 253) !important; color: rgb(51, 51, 51); float: none; clear: both; font-size: 12px !important; line-height: 15px !important; height: auto;"><div style="border: 0px; padding: 0px; margin: 0px; width: 624px; overflow: hidden; max-height: 500px; position: relative; z-index: 1; background-position: 0px 50%;"><table style="border: none !important; padding: 0px !important; margin: 0px 0px 0px -18px !important; background-image: none !important; width: auto !important; border-spacing: 0px !important; border-collapse: collapse !important;"><tbody><tr style="padding: 0px !important; border: none !important; vertical-align: top !important; margin: 0px !important; background-position: 0px 50%;"><td style="vertical-align: top !important; border: 0px; padding: 0px !important; margin: 0px !important; background-color: rgb(223, 239, 255) !important; color: rgb(84, 153, 222) !important;"><div style="border: 0px; padding: 0px; margin: 0px; background-position: 0px 50%;"><div style="font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; font-size: inherit !important; line-height: inherit !important; height: inherit !important; background-position: 0px 50%;">1</div></div></td><td style="vertical-align: top !important; border: 0px; padding: 0px !important; margin: 0px !important; width: 625px; background-position: 0px 50%;"><div style="background-image: none !important; border: none !important; padding: 0px; margin: 0px; color: rgb(0, 0, 0); white-space: pre; overflow: visible;"><div style="font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; font-size: inherit !important; line-height: inherit !important; height: inherit !important; background-position: 0px 50%;"><span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(255, 128, 0) !important;">#coding:utf-8</span></div></div></td></tr></tbody></table></div></div><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);">或者</p><div style="text-align: left; box-sizing: border-box; overflow: hidden !important; position: relative !important; direction: ltr !important; width: 626px; padding: 0px; margin: 10px 0px; font-family: Monaco, MonacoRegular, 'Courier New', monospace; border: 1px solid rgb(153, 153, 153) !important; text-shadow: none !important; background-color: rgb(253, 253, 253) !important; color: rgb(51, 51, 51); float: none; clear: both; font-size: 12px !important; line-height: 15px !important; height: auto;"><div style="border: 0px; padding: 0px; margin: 0px; width: 624px; overflow: hidden; max-height: 500px; position: relative; z-index: 1; background-position: 0px 50%;"><table style="border: none !important; padding: 0px !important; margin: 0px 0px 0px -18px !important; background-image: none !important; width: auto !important; border-spacing: 0px !important; border-collapse: collapse !important;"><tbody><tr style="padding: 0px !important; border: none !important; vertical-align: top !important; margin: 0px !important; background-position: 0px 50%;"><td style="vertical-align: top !important; border: 0px; padding: 0px !important; margin: 0px !important; background-color: rgb(223, 239, 255) !important; color: rgb(84, 153, 222) !important;"><div style="border: 0px; padding: 0px; margin: 0px; background-position: 0px 50%;"><div style="font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; font-size: inherit !important; line-height: inherit !important; height: inherit !important; background-position: 0px 50%;">1</div></div></td><td style="vertical-align: top !important; border: 0px; padding: 0px !important; margin: 0px !important; width: 625px; background-position: 0px 50%;"><div style="background-image: none !important; border: none !important; padding: 0px; margin: 0px; color: rgb(0, 0, 0); white-space: pre; overflow: visible;"><div style="font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; font-size: inherit !important; line-height: inherit !important; height: inherit !important; background-position: 0px 50%;"><span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(255, 128, 0) !important;">#this is my first program. coding:utf-8 , save as utf-8</span></div></div></td></tr></tbody></table></div></div><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);"></p><div style="color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; line-height: 21px; background-color: rgb(255, 255, 255);"><br></div></div>
</div></body></html>