<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[數聚點: 中級約維安]]></title><description><![CDATA[約維安計畫：用一年的時間培養出能獨當一面的約維安，在這個文明階段，中級約維安需要學習基礎的程式設計能力，包含 SQL、Python 與 R。]]></description><link>https://datainpoint.substack.com/s/jovyans</link><image><url>https://substackcdn.com/image/fetch/$s_!XUts!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F546bc6e8-b295-4597-8630-6ad507c81372_500x500.png</url><title>數聚點: 中級約維安</title><link>https://datainpoint.substack.com/s/jovyans</link></image><generator>Substack</generator><lastBuildDate>Thu, 20 Aug 2026 21:05:28 GMT</lastBuildDate><atom:link href="https://datainpoint.substack.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[DATAINPOINT, INC.]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[datainpoint@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[datainpoint@substack.com]]></itunes:email><itunes:name><![CDATA[Yao-Jen Kuo]]></itunes:name></itunes:owner><itunes:author><![CDATA[Yao-Jen Kuo]]></itunes:author><googleplay:owner><![CDATA[datainpoint@substack.com]]></googleplay:owner><googleplay:email><![CDATA[datainpoint@substack.com]]></googleplay:email><googleplay:author><![CDATA[Yao-Jen Kuo]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[約維安計畫：R 語言自行定義函數]]></title><description><![CDATA[&#31532;&#19977;&#21313;&#36913;]]></description><link>https://datainpoint.substack.com/p/week-thirty-defining-functions-with-r</link><guid isPermaLink="false">https://datainpoint.substack.com/p/week-thirty-defining-functions-with-r</guid><dc:creator><![CDATA[Yao-Jen Kuo]]></dc:creator><pubDate>Fri, 24 Jun 2022 09:00:11 GMT</pubDate><enclosure url="https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/b43d4529-5fd9-494b-ac10-dd53297d3f3b_384x270.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!PXtk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F8a6d7377-e64e-4b51-afed-e6fb32693f36_384x270.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!PXtk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F8a6d7377-e64e-4b51-afed-e6fb32693f36_384x270.gif 424w, https://substackcdn.com/image/fetch/$s_!PXtk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F8a6d7377-e64e-4b51-afed-e6fb32693f36_384x270.gif 848w, https://substackcdn.com/image/fetch/$s_!PXtk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F8a6d7377-e64e-4b51-afed-e6fb32693f36_384x270.gif 1272w, https://substackcdn.com/image/fetch/$s_!PXtk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F8a6d7377-e64e-4b51-afed-e6fb32693f36_384x270.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!PXtk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F8a6d7377-e64e-4b51-afed-e6fb32693f36_384x270.gif" width="384" height="270" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/8a6d7377-e64e-4b51-afed-e6fb32693f36_384x270.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:270,&quot;width&quot;:384,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:146733,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!PXtk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F8a6d7377-e64e-4b51-afed-e6fb32693f36_384x270.gif 424w, https://substackcdn.com/image/fetch/$s_!PXtk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F8a6d7377-e64e-4b51-afed-e6fb32693f36_384x270.gif 848w, https://substackcdn.com/image/fetch/$s_!PXtk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F8a6d7377-e64e-4b51-afed-e6fb32693f36_384x270.gif 1272w, https://substackcdn.com/image/fetch/$s_!PXtk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F8a6d7377-e64e-4b51-afed-e6fb32693f36_384x270.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#20358;&#28304;&#65306;giphy.com</figcaption></figure></div><h2>&#35299;&#26512;&#21704;&#22217;&#19990;&#30028;</h2><p>&#22312;<a href="https://datainpoint.substack.com/p/week-twenty-three-getting-started-with-r">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;R &#35486;&#35328;&#36215;&#27493;&#36208;</a>&#25105;&#20497;&#36879;&#36942; <code>print("Hello, World!") &#20358;</code>&#30906;&#35469; R &#35486;&#35328;&#30340;&#38283;&#30332;&#29872;&#22659;&#21450;&#22519;&#34892;&#29872;&#22659;&#26159;&#21542;&#24050;&#32147;&#23433;&#35037;&#22949;&#30070;&#65292;&#22312;&#36889;&#19968;&#27573;&#21704;&#22217;&#19990;&#30028;&#30340;&#31243;&#24335;&#30908;&#20013;&#65292;&#20854;&#23526;&#23601;&#33021;&#39636;&#26371;&#25105;&#20497;&#24341;&#29992; Greg Martin &#23565;&#26044; R &#35486;&#35328;&#26680;&#24515;&#31934;&#31070;&#30340;&#35438;&#37323;&#65306;&#23565;&#36039;&#26009;&#32080;&#27083;&#25033;&#29992;&#20989;&#25976;&#12290;</p><blockquote><p>The way R works is pretty straightforward, you apply functions to objects.</p><p><a href="https://www.youtube.com/user/drgregmartin">Greg Martin</a></p></blockquote><p><code>print</code> &#26159;&#20989;&#25976;&#30340;&#21517;&#31281;&#65292;<code>print()</code> &#21063;&#34920;&#31034;&#35201;&#25033;&#29992;&#35442;&#20989;&#25976;&#30340;&#21151;&#33021;&#65292;&#32780; <code>&#8220;Hello, World!&#8220;</code> &#21063;&#26159;&#19968;&#20491;&#34987;&#31281;&#21628;&#28858;&#25991;&#23383;&#65288;Character&#65289;&#30340;&#21521;&#37327;&#36039;&#26009;&#32080;&#27083;&#65307;&#25563;&#35328;&#20043;&#65292;&#21704;&#22217;&#19990;&#30028;&#21487;&#20197;&#34920;&#36948;&#28858;&#65306;&#23565; <code>&#8220;Hello, World!&#8220;</code> &#36889;&#20491;&#25991;&#23383;&#21521;&#37327;&#25033;&#29992;&#20102; <code>print()</code> &#20989;&#25976;&#12290;</p><pre><code>print("Hello, World!")</code></pre><h2>&#20160;&#40636;&#26159;&#20989;&#25976;</h2><p>&#20989;&#25976;&#26159;&#27083;&#25104;&#25152;&#26377;&#31243;&#24335;&#35486;&#35328;&#30340;&#22522;&#26412;&#35201;&#32032;&#65292;&#19968;&#20491;&#20989;&#25976;&#26159;&#19968;&#27573;&#12300;&#34987;&#21629;&#21517;&#12301;&#30340;&#31243;&#24335;&#30908;&#65292;&#36889;&#27573;&#31243;&#24335;&#30908;&#21487;&#20197;&#29992;&#26044;&#22519;&#34892;&#26576;&#20491;&#29305;&#23450;&#20219;&#21209;&#65292;&#21487;&#33021;&#26159;&#25976;&#20540;&#30340;&#36939;&#31639;&#25110;&#32773;&#25991;&#23383;&#30340;&#34389;&#29702;&#65292;&#30070;&#20351;&#29992;&#32773;&#24819;&#35201;&#25033;&#29992;&#65288;&#20351;&#29992;&#12289;&#21628;&#21483;&#65289;&#26576;&#19968;&#20491;&#20989;&#25976;&#20043;&#21069;&#65292;&#24517;&#38920;&#20808;&#30906;&#23450;&#22312;&#27442;&#29986;&#29983;&#20316;&#29992;&#30340;&#31684;&#30087;&#20013;&#35442;&#20989;&#25976;&#24050;&#32147;&#34987;&#23450;&#32681;&#25110;&#32773;&#34987;&#36617;&#20837;&#12290;&#31777;&#32780;&#35328;&#20043;&#65292;&#22312;&#21704;&#22217;&#19990;&#30028;&#30340;&#31243;&#24335;&#30908;&#20013;&#65292;&#20043;&#25152;&#20197;&#33021;&#22816;&#23565;&#23383;&#20018; <code>&#8220;Hello, World!&#8220;</code> &#25033;&#29992; <code>print()</code> &#20989;&#25976;&#65292;&#26159;&#22240;&#28858; <code>print()</code> &#20989;&#25976;&#23660;&#26044; R &#35486;&#35328;&#30340;&#20839;&#24314;&#20989;&#25976;&#65292;&#22312; R &#35486;&#35328;&#21855;&#21205;&#30340;&#30070;&#19979;&#23601;&#26371;&#34987;&#36617;&#20837;&#20379;&#25105;&#20497;&#20351;&#29992;&#12290;</p><h2>&#20989;&#25976;&#30340;&#20358;&#28304;</h2><p>R &#35486;&#35328;&#20351;&#29992;&#32773;&#38500;&#20102;&#33021;&#22816;&#25033;&#29992;&#20839;&#24314;&#20989;&#25976;&#20197;&#22806;&#65292;&#36996;&#21487;&#20197;&#24478;&#20854;&#20182;&#20841;&#20491;&#31649;&#36947;&#21462;&#24471;&#25152;&#38656;&#35201;&#30340;&#20989;&#25976;&#65306;</p><ol><li><p>&#22871;&#20214;&#65288;Packages&#65289;&#12290;</p></li><li><p>&#33258;&#34892;&#23450;&#32681;&#12290;</p></li></ol><p>&#33258;&#34892;&#23450;&#32681;&#20989;&#25976;&#38656;&#35201;&#32771;&#24942;&#20116;&#20491;&#32068;&#25104;&#35201;&#20214;&#65306;</p><ol><li><p>&#20989;&#25976;&#21517;&#31281;&#12290;</p></li><li><p>&#36664;&#20837;&#12290;</p></li><li><p>&#21443;&#25976;&#12290;</p></li><li><p>&#20989;&#25976;&#20027;&#39636;&#12290;</p></li><li><p>&#36664;&#20986;&#12290;</p></li></ol><p>&#30475;&#20284;&#25277;&#35937;&#65292;&#19981;&#36942;&#24819;&#24819;&#24179;&#26085;&#36092;&#36023;&#29645;&#29664;&#39854;&#22902;&#33590;&#30340;&#27969;&#31243;&#65292;&#23601;&#20687;&#26159;&#20989;&#25976;&#30340;&#36939;&#20316;&#19968;&#33324;&#65306;</p><ol><li><p>&#20989;&#25976;&#21517;&#31281;&#65306;&#36092;&#36023;&#29645;&#29664;&#39854;&#22902;&#33590;&#12290;</p></li><li><p>&#36664;&#20837;&#65306;&#20013;&#26479; 35 &#20803;&#65307;&#22823;&#26479; 50 &#20803;&#12290;</p></li><li><p>&#21443;&#25976;&#65306;&#29980;&#24230;&#65288;&#28961;&#31958;&#12289;&#24494;&#31958;&#12289;&#21322;&#31958;&#12289;&#23569;&#31958;&#12289;&#20840;&#31958;&#65289;&#33287;&#20912;&#22602;&#65288;&#21435;&#20912;&#12289;&#23569;&#20912;&#12289;&#20840;&#20912;&#65289;&#12290;</p></li><li><p>&#20989;&#25976;&#20027;&#39636;&#65306;&#40670;&#39184;&#12289;&#36028;&#27161;&#31844;&#12289;&#21152;&#29645;&#29664;&#12289;&#21152;&#20912;&#22602;&#12289;&#20498;&#33590;&#12289;&#21152;&#39854;&#22902;&#19968;&#30452;&#21040;&#23553;&#21475;&#12290;</p></li><li><p>&#36664;&#20986;&#65306;&#29645;&#29664;&#39854;&#22902;&#33590;&#12290;</p></li></ol><pre><code>function_name &lt;- function(INPUTS, PARAMETERS){
    # body of the function
    # ...
    # ...sequence of statements
    return(OUTPUTS)
}</code></pre><p>&#39318;&#20808;&#35201;&#32102;&#20989;&#25976;&#21462;&#20491;&#21517;&#23383;&#65288;<code>function_name</code>&#65289;&#65292;&#21033;&#29992;&#20445;&#30041;&#23383; <code>function</code> &#21578;&#35380; R &#35486;&#35328;&#36889;&#26159;&#19968;&#20491;&#20989;&#25976;&#65292;&#25509;&#33879;&#22312;&#23567;&#25324;&#34399;&#20013;&#25918;&#20837;&#24819;&#22909;&#30340;&#36664;&#20837;&#65288;<code>INPUTS</code>&#65289;&#33287;&#21443;&#25976;&#65288;<code>PARAMETERS</code>&#65289;&#65292;&#28982;&#24460;&#22312;&#22823;&#25324;&#34399;&#20839;&#32302;&#25490;&#25776;&#23531;&#25105;&#20497;&#20027;&#35201;&#30340;&#31243;&#24335;&#65288;body of the function&#65289;&#65292;&#26368;&#24460;&#26159;&#23559;&#36664;&#20986;&#65288;OUTPUTS&#65289;&#25918;&#22312; <code>return()</code> &#35041;&#38957;&#12290;<code>#</code>&nbsp;&#26159;&#29992;&#20358;&#27161;&#35352;&#35387;&#35299;&#30340;&#31526;&#34399;&#65292;&#26377; <code>#</code> &#27161;&#35352;&#30340;&#35442;&#34892;&#25944;&#36848;&#23559;&#19981;&#26371;&#34987; R &#35486;&#35328;&#22519;&#34892;&#65292;&#36889;&#35731;&#23531;&#31243;&#24335;&#30340;&#20154;&#33021;&#22816;&#29992;&#21475;&#35486;&#20358;&#25551;&#36848;&#36889;&#27573;&#31243;&#24335;&#30340;&#30446;&#30340;&#26159;&#20160;&#40636;&#65292;&#22914;&#26524;&#23559;&#21704;&#22217;&#19990;&#30028;&#25913;&#23531;&#28858;&#20989;&#25976;&#24418;&#24335;&#65292;&#27599;&#27425;&#21482;&#38656;&#35201;&#36664;&#20837;&#20989;&#25976;&#21517;&#31281;&#20006;&#21152;&#19978;&#23567;&#25324;&#34399; <code>hello_world()</code>&#65292;&#23601;&#21487;&#20197;&#29554;&#24471; <code>&#8220;Hello, World!&#8220;</code> &#36889;&#20491;&#25991;&#23383;&#21521;&#37327;&#28858;&#36664;&#20986;&#12290;</p><pre><code>hello_world &lt;- function(){
    return("Hello, World!")
}
print(hello_world())</code></pre><h2>&#36664;&#20837;&#33287;&#21443;&#25976;&#30340;&#24046;&#21029;</h2><pre><code>function_name &lt;- function(INPUTS, PARAMETERS){
    # body of the function
    # ...
    # ...sequence of statements
    return(OUTPUTS)
}</code></pre><p>&#22312; R &#35486;&#35328;&#20013;&#36664;&#20837;&#26371;&#35373;&#35336;&#28858;&#12300;&#28961;&#12301;&#25110;&#32773;&#12300;&#24517;&#35201;&#12301;&#65292;&#21443;&#25976;&#21063;&#26371;&#32102;&#20104;&#38928;&#35373;&#20540;&#65292;&#20363;&#22914; <code>Sys.Date()</code> &#20989;&#25976;&#25110; <code>getwd()</code> &#37117;&#26159;&#28961;&#38656;&#36664;&#20837;&#30340;&#20989;&#25976;&#65292;&#20989;&#25976;&#21517;&#31281;&#24460;&#30340;&#23567;&#25324;&#34399;&#30041;&#31354;&#30333;&#12290;</p><pre><code>print(Sys.Date())
print(getwd())</code></pre><p><code>&#20363;&#22914;</code> <code>sort()</code> &#20989;&#25976;&#20855;&#26377; <code>decreasing</code> &#21443;&#25976;&#65292;&#38928;&#35373;&#20540;&#32102;&#23450;&#28858; <code>FALSE</code>&#12290;&#25152;&#20197;&#22312;&#27794;&#26377;&#20659;&#20837;&#30340;&#29376;&#27841;&#19979;&#65292;&#20854;&#23526;&#23601;&#26159;&#25505;&#29992; <code>decreasing = FALSE</code> &#30340;&#21443;&#25976;&#35373;&#23450;&#65292;&#20551;&#20351;&#19981;&#24819;&#25505;&#29992;&#38928;&#35373;&#20540;&#65292;&#23601;&#33021;&#25351;&#23450;&#21443;&#25976; <code>decreasing = TRUE</code>&#12290;</p><pre><code>primes &lt;- c(11, 5, 7, 2, 3)
print(sort(primes))
print(sort(primes, decreasing = TRUE))</code></pre><h2>&#26356;&#21205;&#32080;&#26524;&#30340;&#27231;&#21046;</h2><p>&#20351;&#29992;&#12300;&#20989;&#25976;&#12301;&#21487;&#20197;&#35731;&#25033;&#29992;&#30340;&#23565;&#35937;&#29289;&#20214;&#36896;&#25104;&#26356;&#21205;&#65292;&#26356;&#21205;&#26041;&#24335;&#26159;&#20197;&#12300;&#22238;&#20659;&#20540;&#12301;&#22411;&#24907;&#36664;&#20986;&#26356;&#21205;&#24460;&#30340;&#32080;&#26524;&#65292;&#24310;&#32396;&#21069;&#36848; <code>sort()</code> &#20989;&#25976;&#30340;&#20363;&#23376;&#65292;<code>sort(</code>primes<code>)</code>&nbsp;&#26159;&#20197;&#22238;&#20659;&#20540;&#36664;&#20986;&#25490;&#24207;&#24460;&#30340;&#21521;&#37327;&#65292;&#22914;&#26524;&#27794;&#26377;&#23559;&#22238;&#20659;&#20540;&#26356;&#26032;&#21407;&#26412;&#21629;&#21517;&#30340;&#21521;&#37327;&#65292;&#25490;&#24207;&#30340;&#26356;&#21205;&#20006;&#19981;&#26371;&#34987;&#20445;&#30041;&#12290;</p><pre><code>primes &lt;- c(11, 5, 7, 2, 3)
print(sort(primes))
sort(primes) # Apply sort function to primes
print(primes) # primes is not sorted 
primes &lt;- sort(primes) # Update primes with function output
print(primes) # primes is sorted</code></pre><h2>&#20316;&#29992;&#22495;</h2><p>&#22312;<a href="https://datainpoint.substack.com/p/week-twenty-eight-control-flow-in-r">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;R &#35486;&#35328;&#30340;&#27969;&#31243;&#25511;&#21046;</a>&#25105;&#20497;&#25552;&#21040;&#20102;&#31243;&#24335;&#21312;&#22602;&#65288;Code blocks&#65289;&#30340;&#35264;&#24565;&#65292;&#19981;&#35542;&#26159;&#26781;&#20214;&#21028;&#26039;&#25110;&#32773;&#36852;&#22280;&#65292;&#37117;&#20208;&#36084;&#19968;&#23565;&#22823;&#25324;&#34399;&#65288;A curly-brace pair&#65289;&#24314;&#31435;&#20986;&#31243;&#24335;&#21312;&#22602;&#65292;&#20006;&#20197;&#27492;&#20316;&#28858;&#25944;&#36848;&#30340;&#38468;&#23660;&#12290;&#22312;&#33258;&#34892;&#23450;&#32681;&#20989;&#25976;&#26178;&#20063;&#21516;&#27171;&#20197;&#31243;&#24335;&#21312;&#22602;&#24314;&#27083;&#20986;&#20989;&#25976;&#20027;&#39636;&#65292;&#19981;&#36942;&#26356;&#29305;&#21029;&#30340;&#26159;&#65292;&#38468;&#23660;&#26044; <code>function</code> &#20445;&#30041;&#23383;&#30340;&#31243;&#24335;&#21312;&#22602;&#20855;&#26377;&#19968;&#20491;&#31281;&#28858;&#20316;&#29992;&#22495;&#65288;&#25110;&#31281;&#31684;&#30087; Scope&#65289;&#30340;&#35264;&#24565;&#65292;&#22312;&#38468;&#23660;&#26044;&#20989;&#25976;&#19979;&#30340;&#31243;&#24335;&#21312;&#22602;&#34987;&#31281;&#28858; Local scope&#65292;&#20989;&#25976;&#20197;&#22806;&#30340;&#37096;&#20998;&#21063;&#31281;&#28858; Global scope&#12290;&#22312; Local scope &#20013;&#25105;&#20497;&#21487;&#20197;&#36939;&#29992; INPUTS&#12289;PARAMETERS &#20358;&#36914;&#34892;&#36939;&#31639;&#20006;&#23459;&#21578;&#26032;&#30340;&#29289;&#20214;&#65292;&#20294;&#26159;&#36889;&#37117;&#20407;&#38480;&#26044; Local scope &#20043;&#20013;&#65292;&#19968;&#20294;&#22312; Global scope &#24847;&#22294;&#36939;&#29992;&#21069;&#36848;&#30340;&#36889;&#20123;&#29289;&#20214;&#65292;&#37117;&#26371;&#36973;&#36935;&#21040;&#37679;&#35492;&#65292;&#24847;&#21363;&#22312; Global scope &#20013;&#36889;&#20123;&#29289;&#20214;&#12300;&#27794;&#26377;&#20316;&#29992;&#12301;&#65292;&#36889;&#20063;&#26159;&#20316;&#29992;&#22495;&#19968;&#35422;&#30340;&#30001;&#20358;&#12290;&#20363;&#22914;&#22312; Global scope &#20013;&#35430;&#22294;&#21360;&#20986;&#20219;&#20309;&#22312; Local scope &#20013;&#21487;&#20197;&#36939;&#29992;&#30340;&#29289;&#20214;&#37117;&#26371;&#36973;&#36935;&#37679;&#35492;&#12290;</p><pre><code>is_factor &lt;- function(a, b){
  modulo &lt;- a %% b
  out &lt;- modulo == 0
  return(out)
}

print(is_factor(4, 2))
print(a)
## Error in print(a) : object 'a' not found
print(b)
## Error in print(b) : object 'b' not found
print(modulo)
## Error in print(modulo) : object 'modulo' not found
print(out)
## Error in print(out) : object 'out' not found</code></pre><h2>return() &#30340;&#20316;&#29992;</h2><p>&#21021;&#27425;&#23416;&#32722;&#33258;&#34892;&#23450;&#32681;&#20989;&#25976;&#22810;&#21322;&#37117;&#19981;&#29978;&#26296;&#35299; <code>return()</code> &#20316;&#29992;&#65292;&#21407;&#22240;&#26159;&#20808;&#21069;&#22826;&#36942;&#38971;&#32321;&#22320;&#20351;&#29992; <code>print()</code> &#20989;&#25976;&#23559;&#25991;&#23383;&#34389;&#29702;&#12289;&#25976;&#20540;&#35336;&#31639;&#25110;&#32773;&#36039;&#26009;&#32080;&#27083;&#25805;&#20316;&#30340;&#32080;&#26524;&#39023;&#31034;&#20986;&#20358;&#65292;&#23566;&#33268;&#22312;&#33258;&#34892;&#23450;&#32681;&#20989;&#25976;&#26178;&#19981;&#32722;&#24931;&#21435;&#20351;&#29992; <code>return()</code>&#12290;&#20107;&#23526;&#19978;&#65292;<code>return()</code> &#20855;&#26377;&#20841;&#20491;&#20316;&#29992;&#65292;&#31532;&#19968;&#20491;&#36319;&#23383;&#38754;&#19978;&#24847;&#32681;&#30456;&#21516;&#30340;&#23559;&#20989;&#25976;&#32080;&#26524;&#12300;&#36664;&#20986;&#12301;&#65292;&#20551;&#22914;&#22312;&#33258;&#34892;&#23450;&#32681;&#20989;&#25976;&#26178;&#21482;&#26377;&#23559;&#36939;&#31639;&#32080;&#26524;&#29992; <code>print()</code> &#20989;&#25976;&#39023;&#31034;&#20986;&#20358;&#65292;&#35442;&#20989;&#25976;&#23601;&#19981;&#20855;&#20633;&#33021;&#23559;&#32080;&#26524;&#20786;&#23384;&#22312;&#29289;&#20214;&#20013;&#30340;&#33021;&#21147;&#65292;&#35722;&#25104;&#21482;&#33021;&#22816;&#22312;&#20351;&#29992;&#26178;&#39023;&#31034;&#32080;&#26524;&#65292;&#21371;&#19981;&#33021;&#23559;&#32080;&#26524;&#20786;&#23384;&#36215;&#20358;&#12290;&#31532;&#19968;&#20491;&#29305;&#24615;&#22312; R &#35486;&#35328;&#20013;&#21487;&#33021;&#27604;&#36611;&#38627;&#24863;&#21463;&#21040;&#65292;&#21407;&#22240;&#26159; R &#35486;&#35328;&#28858;&#20102;&#24171;&#21161;&#20351;&#29992;&#32773;&#65292;&#26371;&#38928;&#35373;&#23559;&#20989;&#25976;&#20027;&#39636;&#21312;&#22602;&#20013;&#30340;&#26368;&#24460;&#19968;&#34892;&#29289;&#20214;&#36664;&#20986;&#65292;&#20363;&#22914;&#19979;&#21015;&#33258;&#34892;&#23450;&#32681;&#20989;&#25976;&#20006;&#27794;&#26377;&#25351;&#23450;&#23559;&#21028;&#26039;&#22240;&#25976;&#30340;&#32080;&#26524;&#36664;&#20986;&#65292;&#20381;&#28982;&#33021;&#24471;&#21040;<code>&#38928;&#26399;&#32080;&#26524;</code>&#12290;</p><pre><code>is_factor &lt;- function(a, b){
  modulo &lt;- a %% b
  out &lt;- modulo == 0
}

function_output &lt;- is_factor(4, 2)
print(function_output)</code></pre><p>&#31532;&#20108;&#20491;&#26159;&#32066;&#27490;&#31243;&#24335;&#21312;&#22602;&#30340;&#22519;&#34892;&#65292;&#22312;&#20989;&#25976;&#31243;&#24335;&#21312;&#22602;&#20013;&#23531;&#22312; <code>return()</code> &#20043;&#24460;&#30340;&#25152;&#26377;&#20839;&#23481;&#22312;&#20351;&#29992;&#20989;&#25976;&#30340;&#26178;&#20505;&#37117;&#19981;&#26371;&#26377;&#20219;&#20309;&#20316;&#29992;&#12290;</p><pre><code>is_factor &lt;- function(a, b){
  modulo &lt;- a %% b
  return(modulo)
  out &lt;- modulo == 0 # will not be returned
  print(out) # # will not be printed
}

function_output &lt;- is_factor(4, 2)
print(function_output)</code></pre><h2>&#36664;&#20837;&#33287;&#36664;&#20986;&#30340;&#23565;&#25033;&#38364;&#20418;</h2><p>&#33258;&#34892;&#23450;&#32681;&#20989;&#25976;&#30340;&#37325;&#40670;&#22312;&#26044;&#35215;&#21123;&#36664;&#20837;&#33287;&#36664;&#20986;&#30340;&#23565;&#25033;&#38364;&#20418;&#65292;&#22914;&#21516;&#22312;&#25976;&#23416;&#35506;&#20013;&#23416;&#36942;&#30340;&#12300;&#20989;&#25976;&#26144;&#23556;&#38364;&#20418;&#12301;&#65292;&#21482;&#35201;&#37328;&#28165;&#20102;&#33258;&#34892;&#23450;&#32681;&#20989;&#25976;&#37341;&#23565;&#36664;&#20837;&#33287;&#36664;&#20986;&#30340;&#35373;&#35336;&#27231;&#21046;&#65292;&#21097;&#19979;&#30340;&#20219;&#21209;&#23601;&#20677;&#26159;&#23559;&#31243;&#24335;&#21312;&#22602;&#30340;&#20989;&#25976;&#20027;&#39636;&#23436;&#25104;&#32780;&#24050;&#12290;</p><p>&#24478;&#36664;&#20837;&#38283;&#22987;&#65292;&#20989;&#25976;&#21487;&#20197;&#25509;&#21463;&#27794;&#26377;&#36664;&#20837;&#33287;&#21443;&#25976;&#30340;&#35373;&#35336;&#65292;&#22312;&#23567;&#25324;&#34399;&#20013;&#30041;&#31354;&#21363;&#21487;&#12290;</p><pre><code>hello_world &lt;- function(){
  return("Hello, World!")
}
print(hello_world())</code></pre><p>&#20989;&#25976;&#30070;&#28982;&#21487;&#20197;&#25509;&#21463;&#26377;&#36664;&#20837;&#33287;&#21443;&#25976;&#30340;&#35373;&#35336;&#65292;&#22909;&#30340;&#20989;&#25976;&#35373;&#35336;&#26371;&#22312;&#21443;&#25976;&#32102;&#20104;&#21512;&#36969;&#30340;&#38928;&#35373;&#20540;&#12290;</p><pre><code>hello_someone &lt;- function(someone = "World"){
  out &lt;- sprintf("Hello, %s!", someone)
  return(out)
}

print(hello_someone())
print(hello_someone(someone="Function"))</code></pre><p>&#35373;&#35336;&#25509;&#21463;&#22810;&#20491;&#36664;&#20837;&#20540;&#30340;&#20989;&#25976;&#26178;&#65292;&#22240;&#28858; R &#35486;&#35328;&#30340;&#21521;&#37327;&#12289;&#20803;&#32032;&#36939;&#31639;&#65288;Element-wise&#65289;&#29305;&#24615;&#65292;&#30452;&#25509;&#20351;&#29992;&#21512;&#36969;&#30340;&#36039;&#26009;&#32080;&#27083;&#23481;&#32013;&#22810;&#20491;&#36664;&#20837;&#36039;&#26009;&#21363;&#21487;&#12290;</p><pre><code>square_multiple_integers &lt;- function(x){
  return(x**2)
}

print(square_multiple_integers(c(2, 3)))
print(square_multiple_integers(c(2, 3, 5)))</code></pre><p>&#22810;&#20491;&#36664;&#20986;&#30340;&#34389;&#29702;&#21516;&#27171;&#26159;&#25505;&#29992;&#36969;&#30070;&#30340;&#36039;&#26009;&#32080;&#27083;&#20786;&#23384;&#65292;&#20687;&#26159;&#29992; <code>list</code> &#20786;&#23384;&#20841;&#20491;&#21521;&#37327;&#30340;&#30456;&#21152;&#33287;&#30456;&#28187;&#12290;</p><pre><code>add_subtract_vectors &lt;- function(a, b){
  out &lt;- list(
    "add" = a + b,
    "subtract" = a - b
  )
  return(out)
}

function_output_as_list = add_subtract_vectors(3, 4)
print(function_output_as_list)</code></pre><p>&#22312;&#35469;&#35672;&#20102;&#20989;&#25976;&#30340;&#21508;&#31278;&#30473;&#30473;&#35282;&#35282;&#20043;&#24460;&#65292;&#31532;&#19977;&#21313;&#36913;&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;R &#35486;&#35328;&#33258;&#34892;&#23450;&#32681;&#20989;&#25976;&#20358;&#21040;&#23614;&#32882;&#65292;&#24076;&#26395;&#24744;&#20063;&#21644;&#25105;&#19968;&#27171;&#26399;&#24453;&#19979;&#19968;&#31687;&#25991;&#31456;&#12290;</p><p>&#23565;&#26044;&#36889;&#31687;&#25991;&#31456;&#26377;&#20160;&#40636;&#24819;&#27861;&#21602;&#65311;&#21916;&#27489;&#128571;&#12289;&#30041;&#35328;&#128587;&#8205;&#9794;&#65039;&#25110;&#32773;&#20998;&#20139;&#128588;</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://datainpoint.substack.com/p/week-thirty-defining-functions-with-r/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://datainpoint.substack.com/p/week-thirty-defining-functions-with-r/comments"><span>Leave a comment</span></a></p><h2>&#32004;&#32173;&#23433;&#35336;&#30059;&#23416;&#21729;&#23560;&#21312;</h2>
      <p>
          <a href="https://datainpoint.substack.com/p/week-thirty-defining-functions-with-r">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[約維安計畫：常用的 R 語言內建函數]]></title><description><![CDATA[&#20108;&#21313;&#20061;&#36913;]]></description><link>https://datainpoint.substack.com/p/week-twenty-nine-builtin-functions-in-r</link><guid isPermaLink="false">https://datainpoint.substack.com/p/week-twenty-nine-builtin-functions-in-r</guid><dc:creator><![CDATA[Yao-Jen Kuo]]></dc:creator><pubDate>Sun, 08 May 2022 08:00:47 GMT</pubDate><enclosure url="https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/b02b840d-4e02-4542-be0c-ff83c9859a10_480x264.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!I4zh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F307466fe-dd9f-4694-b7c9-ad1e9032a029_480x264.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!I4zh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F307466fe-dd9f-4694-b7c9-ad1e9032a029_480x264.gif 424w, https://substackcdn.com/image/fetch/$s_!I4zh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F307466fe-dd9f-4694-b7c9-ad1e9032a029_480x264.gif 848w, https://substackcdn.com/image/fetch/$s_!I4zh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F307466fe-dd9f-4694-b7c9-ad1e9032a029_480x264.gif 1272w, https://substackcdn.com/image/fetch/$s_!I4zh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F307466fe-dd9f-4694-b7c9-ad1e9032a029_480x264.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!I4zh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F307466fe-dd9f-4694-b7c9-ad1e9032a029_480x264.gif" width="480" height="264" data-attrs="{&quot;src&quot;:&quot;https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_lossy/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F307466fe-dd9f-4694-b7c9-ad1e9032a029_480x264.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:264,&quot;width&quot;:480,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1493492,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!I4zh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F307466fe-dd9f-4694-b7c9-ad1e9032a029_480x264.gif 424w, https://substackcdn.com/image/fetch/$s_!I4zh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F307466fe-dd9f-4694-b7c9-ad1e9032a029_480x264.gif 848w, https://substackcdn.com/image/fetch/$s_!I4zh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F307466fe-dd9f-4694-b7c9-ad1e9032a029_480x264.gif 1272w, https://substackcdn.com/image/fetch/$s_!I4zh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F307466fe-dd9f-4694-b7c9-ad1e9032a029_480x264.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#20358;&#28304;&#65306;giphy.com</figcaption></figure></div><p>&#20989;&#25976;&#26159; R &#35486;&#35328;&#30340;&#26680;&#24515;&#65292;&#33509;&#26159;&#24819;&#25104;&#28858;&#25797;&#38263;&#23531;&#20316; R &#35486;&#35328;&#30340;&#36039;&#26009;&#20998;&#26512;&#24107;&#65292;&#24517;&#38920;&#23565;&#20989;&#25976;&#26377;&#19968;&#23450;&#31243;&#24230;&#30340;&#25484;&#25569;&#12290;&#20107;&#23526;&#19978;&#26089;&#22312;&#36889;&#20491;&#31456;&#31680;&#20043;&#21069;&#25105;&#20497;&#23601;&#38283;&#22987;&#22823;&#37327;&#20351;&#29992;&#20989;&#25976;&#20102;&#65292;&#19981;&#31649;&#26159;&#24314;&#31435;&#21521;&#37327;&#26178;&#20351;&#29992;&#30340; <code>c()</code> &#20989;&#25976;&#12289;&#24314;&#31435;&#28165;&#21934;&#26178;&#20351;&#29992;&#30340; <code>list()</code> &#20989;&#25976;&#25110;&#32773;&#26159;&#27298;&#26597;&#39006;&#22411;&#30340; <code>class()</code> <code>&#20989;&#25976;</code>&#65292;&#37117;&#26159;&#24120;&#29992;&#30340;&#20989;&#25976;&#12290;</p><p>&#23565;&#21021;&#23416;&#32773;&#20358;&#35498;&#65292;&#23565;&#29031;&#36664;&#20986;&#26684;&#24335;&#33287;&#20839;&#23481;&#31526;&#21512;&#25152;&#38928;&#26399;&#30340;&#36664;&#20837;&#33287;&#21443;&#25976;&#65292;&#26159;&#20351;&#29992;&#20989;&#25976;&#26178;&#30340;&#33391;&#22909;&#34892;&#28858;&#34892;&#28858;&#12290;&#25509;&#33879;&#25105;&#20497;&#24409;&#25972;&#19968;&#20123;&#24120;&#29992;&#30340; R &#35486;&#35328;&#31995;&#32113;&#21151;&#33021;&#20989;&#25976;&#65288;Utility functions&#65289;&#12289;&#25976;&#20540;&#21521;&#37327;&#20989;&#25976;&#65288;Numeric functions&#65289;&#12289;&#25991;&#23383;&#21521;&#37327;&#20989;&#25976;&#65288;Character functions&#65289;&#33287;&#25551;&#36848;&#32113;&#35336;&#20989;&#25976;&#12290;</p><h2>&#31995;&#32113;&#21151;&#33021;&#20989;&#25976;</h2><p>&#31995;&#32113;&#21151;&#33021;&#20989;&#25976;&#21487;&#20197;&#24171;&#21161;&#20351;&#29992;&#32773;&#23559; R &#35486;&#35328;&#33287;&#38651;&#33126;&#31995;&#32113;&#36899;&#32080;&#65292;&#24120;&#29992;&#30340;&#26377;&#65306;</p><ul><li><p><code>print()</code></p></li><li><p><code>rm()</code></p></li><li><p><code>help()</code></p></li><li><p><code>sessionInfo()</code></p></li><li><p><code>Sys.getlocale()</code></p></li><li><p><code>getwd()</code></p></li><li><p><code>setwd()</code></p></li></ul><p><code>print()</code> &#20989;&#25976;&#21487;&#20197;&#23559;&#29289;&#20214;&#30340;&#39023;&#31034;&#20839;&#23481;&#21360;&#20986;&#22312; Console&#12290;</p><pre><code>hello_world &lt;- "Hello, World!"
print(hello_world)</code></pre><p><code>rm()</code> &#20989;&#25976;&#33021;&#22816;&#23559;&#23436;&#25104;&#36070;&#20540;&#30340;&#29289;&#20214;&#33258;&#29872;&#22659;&#20013;&#21034;&#38500;&#65292;&#36889;&#20491;&#20989;&#25976;&#21629;&#21517;&#20358;&#33258; remove &#30340;&#32302;&#23531;&#12290;</p><pre><code>hello_world &lt;- "Hello, World!"
rm(hello_world)
tryCatch(
    {
        print(hello_world)
    }, error = function(e) {
        print("Object removed.")
    }
)</code></pre><p><code>help()</code> &#20989;&#25976;&#21487;&#20197;&#26597;&#35426;&#20839;&#24314;&#36039;&#26009;&#20197;&#21450;&#20989;&#25976;&#30340;&#35498;&#26126;&#25991;&#20214;&#12290;</p><pre><code>help(iris)  # help on built-in dataset, ?iris works too
help(rm)    # help on built-in function, ?rm works too</code></pre><p><code>sessionInfo()</code> &#20989;&#25976;&#26371;&#39023;&#31034; R &#35486;&#35328;&#30340;&#29256;&#26412;&#20197;&#21450;&#20316;&#26989;&#31995;&#32113;&#30456;&#38364;&#36039;&#35338;&#12290;</p><pre><code>sessionInfo()</code></pre><p><code>Sys.getlocale()</code> &#20989;&#25976;&#39023;&#31034;&#38651;&#33126;&#30340;&#22320;&#21312;&#20197;&#21450;&#35486;&#31995;&#36039;&#35338;&#12290;</p><pre><code>Sys.getlocale()</code></pre><p><code>getwd()</code> &#20989;&#25976;&#39023;&#31034; R &#35486;&#35328;&#30340;&#24037;&#20316;&#30446;&#37636;&#65292;&#36889;&#20491;&#20989;&#25976;&#21629;&#21517;&#20358;&#33258; working directory &#30340;&#32302;&#23531;&#12290;</p><pre><code>getwd()</code></pre><p><code>setwd()</code> &#20989;&#25976;&#33021;&#22816;&#35373;&#23450; R &#35486;&#35328;&#30340;&#24037;&#20316;&#30446;&#37636;&#65292;Windows &#20351;&#29992;&#32773;&#35201;&#29305;&#21029;&#27880;&#24847;&#36335;&#24465;&#26012;&#32218;&#35201;&#20351;&#29992;&#27491;&#26012;&#32218; <code>/</code>&#65288;&#32780;&#38750; Windows &#20316;&#26989;&#31995;&#32113;&#20351;&#29992;&#30340;&#21453;&#26012;&#32218; <code>\</code>&#65289;&#65292;&#20006;&#19988;&#36991;&#20813;&#22312;&#36335;&#24465;&#35373;&#23450;&#19978;&#20986;&#29694;&#31354;&#26684;&#33287;&#38750;&#33521;&#25991;&#30340;&#25991;&#23383;&#12290;</p><pre><code>setwd("/Users/YOURUSERNAME/Desktop")   # Set MacOS Desktop as working directory
setwd("C:/Users/YOURUSERNAME/Desktop") # Set Windows Desktop as working director, USE / instead of \</code></pre><h2>&#25976;&#20540;&#21521;&#37327;&#20989;&#25976;</h2><p>&#25976;&#20540;&#21521;&#37327;&#20989;&#25976;&#21487;&#20197;&#37341;&#23565;&#25976;&#20540;&#21521;&#37327;&#20570;&#34389;&#29702;&#25110;&#36939;&#31639;&#65292;&#24120;&#29992;&#30340;&#26377;&#65306;</p><ul><li><p><code>abs()</code></p></li><li><p><code>sqrt()</code></p></li><li><p><code>ceiling()</code></p></li><li><p><code>floor()</code></p></li><li><p><code>round()</code></p></li><li><p><code>exp()</code></p></li><li><p><code>log()</code></p></li><li><p><code>log10()</code></p></li></ul><p><code>abs()</code> &#20989;&#25976;&#33021;&#22816;&#23559;&#36664;&#20837;&#25976;&#20540;&#21521;&#37327;&#20803;&#32032;&#37117;&#36681;&#25563;&#28858;&#32085;&#23565;&#20540;&#65292;&#36889;&#20491;&#20989;&#25976;&#21629;&#21517;&#20358;&#33258; absolute &#30340;&#32302;&#23531;&#12290;</p><pre><code>a_vector &lt;- -5:-1
print(a_vector)
print(abs(a_vector))</code></pre><p><code>sqrt()</code> &#20989;&#25976;&#33021;&#22816;&#23559;&#36664;&#20837;&#25976;&#20540;&#21521;&#37327;&#20803;&#32032;&#37117;&#38283;&#24179;&#26041;&#65292;&#36889;&#20491;&#20989;&#25976;&#21629;&#21517;&#20358;&#33258; square root &#30340;&#32302;&#23531;&#12290;</p><pre><code>a_vector &lt;- c(1, 4, 9, 16, 25)
print(a_vector)
print(sqrt(a_vector))</code></pre><p><code>ceiling()</code> &#20989;&#25976;&#33021;&#22816;&#23559;&#36664;&#20837;&#25976;&#20540;&#21521;&#37327;&#20803;&#32032;&#37117;&#28961;&#26781;&#20214;&#36914;&#20301;&#12290;</p><pre><code>a_vector &lt;- 1:10
sqrt_a_vector &lt;- sqrt(a_vector)
print(sqrt_a_vector)
print(ceiling(sqrt_a_vector))</code></pre><p><code>floor()</code> &#20989;&#25976;&#33021;&#22816;&#23559;&#36664;&#20837;&#25976;&#20540;&#21521;&#37327;&#20803;&#32032;&#37117;&#28961;&#26781;&#20214;&#25448;&#21435;&#12290;</p><pre><code>a_vector &lt;- 1:10
sqrt_a_vector &lt;- sqrt(a_vector)
print(sqrt_a_vector)
print(floor(sqrt_a_vector))</code></pre><p><code>round()</code> &#20989;&#25976;&#33021;&#22816;&#35519;&#25972;&#25976;&#20540;&#21521;&#37327;&#20803;&#32032;&#23567;&#25976;&#20301;&#65292;&#20197; 5 &#20316;&#28858;&#22522;&#28310;&#65292;&#20006;&#38752;&#25871;&#25976;&#32218;&#19978;&#30340;&#20598;&#25976;&#65288;Rounding off a 5, go to the even digit&#65289;&#12290;</p><pre><code>a_vector &lt;- c(-1.5, -0.5, 0.5, 1.5, 2.5, 3.5)
print(round(a_vector))</code></pre><p><code>exp()</code> &#20989;&#25976;&#33021;&#22816;&#23559;&#36664;&#20837;&#25976;&#20540;&#21521;&#37327;&#20803;&#32032;&#35519;&#25972;&#28858;&#20197;&#33258;&#28982;&#23565;&#25976;&#20989;&#25976;&#20043;&#24213;&#25976; <code>e</code> &#30340;&#25351;&#25976;&#65292;&#20854;&#20013; <code>e</code> &#25509;&#36817; <code>2.718282</code>&#12290;</p><pre><code>a_vector &lt;- 1:5
print(exp(a_vector))</code></pre><p><code>log()</code> &#20989;&#25976;&#33021;&#22816;&#23559;&#36664;&#20837;&#25976;&#20540;&#21521;&#37327;&#20803;&#32032;&#21462;&#20197; <code>e</code> &#28858;&#24213;&#25976;&#30340;&#23565;&#25976;&#12290;</p><pre><code>a_vector &lt;- exp(1:5)
print(log(a_vector))</code></pre><p><code>log10()</code> &#20989;&#25976;&#33021;&#22816;&#23559;&#36664;&#20837;&#25976;&#20540;&#21521;&#37327;&#20803;&#32032;&#21462;&#20197; 10 &#28858;&#24213;&#25976;&#30340;&#23565;&#25976;&#12290;</p><pre><code>bases &lt;- rep(10, 5)
exps &lt;- 1:5
a_vector &lt;- bases**exps
print(log10(a_vector))</code></pre><h2>&#25991;&#23383;&#21521;&#37327;&#20989;&#25976;</h2><p>&#25991;&#23383;&#21521;&#37327;&#20989;&#25976;&#21487;&#20197;&#37341;&#23565;&#25991;&#23383;&#21521;&#37327;&#20570;&#34389;&#29702;&#65292;&#24120;&#29992;&#30340;&#26377;&#65306;</p><ul><li><p><code>toupper()</code></p></li><li><p><code>tolower()</code></p></li><li><p><code>substr()</code></p></li><li><p><code>grep()</code></p></li><li><p><code>sub()</code></p></li><li><p><code>strsplit()</code></p></li><li><p><code>paste()</code></p></li><li><p><code>paste0()</code></p></li><li><p><code>trimws()</code></p></li></ul><p><code>toupper()</code> &#20989;&#25976;&#33021;&#22816;&#23559;&#36664;&#20837;&#25991;&#23383;&#21521;&#37327;&#20803;&#32032;&#20840;&#37096;&#36681;&#25563;&#28858;&#22823;&#23531;&#12290;</p><pre><code>skywalkers &lt;- c("Anakin Skywalker", "Luke Skywalker")
print(toupper(skywalkers))</code></pre><p><code>tolower()</code> &#20989;&#25976;&#33021;&#22816;&#23559;&#36664;&#20837;&#25991;&#23383;&#21521;&#37327;&#20803;&#32032;&#20840;&#37096;&#36681;&#25563;&#28858;&#23567;&#23531;&#12290;</p><pre><code>skywalkers &lt;- c("Anakin Skywalker", "Luke Skywalker")
print(tolower(skywalkers))</code></pre><p><code>substr()</code> &#20989;&#25976;&#33021;&#22816;&#23559;&#36664;&#20837;&#25991;&#23383;&#21521;&#37327;&#20803;&#32032;&#25847;&#21462;&#37096;&#20998;&#65292;&#20351;&#29992;&#30340;&#26178;&#20505;&#25645;&#37197;&#20841;&#20491;&#21443;&#25976;&#65292; <code>start</code> &#21443;&#25976;&#25351;&#23450;&#35201;&#24478;&#21738;&#19968;&#20491;&#23383;&#20803;&#20301;&#32622;&#38283;&#22987;&#25847;&#21462;&#65292; <code>stop</code> &#21443;&#25976;&#25351;&#23450;&#35201;&#25847;&#21462;&#21040;&#21738;&#19968;&#20491;&#23383;&#20803;&#20301;&#32622;&#12290;</p><pre><code>luke_skywalker &lt;- "Luke Skywalker"
nchar_luke_skywalker &lt;- nchar(luke_skywalker)
print(substr(luke_skywalker, start = 1, stop = 4))
print(substr(luke_skywalker, start = 6, stop = nchar_luke_skywalker))</code></pre><p><code>grep()</code> &#20989;&#25976;&#33021;&#22816;&#22312;&#25991;&#23383;&#21521;&#37327;&#20013;&#25628;&#23563;&#25351;&#23450;&#27171;&#24335;&#20006;&#23559;&#31526;&#21512;&#25152;&#22312;&#32034;&#24341;&#20540;&#22238;&#20659;&#65292;&#20351;&#29992; <code>pattern</code> &#21443;&#25976;&#25351;&#23450;&#27171;&#24335;&#65292;&#22914;&#26524;&#25628;&#23563;&#24460;&#27794;&#26377;&#31526;&#21512;&#27171;&#24335;&#30340;&#65292;&#21063;&#26371;&#22238;&#20659; <code>integer(0)</code>&#12290;</p><pre><code>starwars &lt;- c("Luke Skywalker", "Princess Leia Organa", "Anakin Skywalker", "Darth Vader")
print(grep(starwars, pattern = "Skywalker"))
print(grep(starwars, pattern = "Leia"))
print(grep(starwars, pattern = "Vader"))
print(grep(starwars, pattern = "Yoda"))</code></pre><p><code>sub()</code> &#20989;&#25976;&#33021;&#22816;&#22312;&#25991;&#23383;&#21521;&#37327;&#20013;&#25628;&#23563;&#21040;&#25351;&#23450;&#27171;&#24335;&#25351;&#23450;&#26367;&#25563;&#28858;&#20854;&#20182;&#20839;&#23481;&#65292;&#20351;&#29992; <code>pattern</code> &#21443;&#25976;&#25351;&#23450;&#27171;&#24335;&#65292;&#20351;&#29992; <code>replacement</code> &#21443;&#25976;&#25351;&#23450;&#35201;&#26367;&#25563;&#30340;&#25991;&#23383;&#65292;&#20197;&#36889;&#20491;&#31684;&#20363;&#20358;&#35498;&#26126;&#65292;&#25105;&#20497;&#23559; <code>"Anakin"</code> &#26367;&#25563;&#28858; <code>"Luke"</code> &#12290;</p><pre><code>anakin_skywalker &lt;- "Anakin Skywalker"
luke_skywalker &lt;- sub(anakin_skywalker, pattern = "Anakin", replacement = "Luke")
print(luke_skywalker)</code></pre><p><code>strsplit()</code> &#20989;&#25976;&#33021;&#22816;&#23559;&#19968;&#20491;&#25991;&#23383;&#21521;&#37327;&#20999;&#21106;&#25104;&#28165;&#21934;&#65292;&#20351;&#29992; <code>split</code> &#21443;&#25976;&#21487;&#20197;&#25351;&#23450;&#35201;&#26681;&#25818;&#20160;&#40636;&#20998;&#21106;&#31526;&#34399;&#20358;&#36914;&#34892;&#25991;&#23383;&#30340;&#20999;&#21106;&#65292;&#20540;&#24471;&#27880;&#24847;&#30340;&#26159;&#36889;&#20491;&#20989;&#25976;&#30340;&#36664;&#20986;&#26159;&#20197;&#28165;&#21934;&#30340;&#36039;&#26009;&#32080;&#27083;&#20786;&#23384;&#12290;</p><pre><code>skywalkers &lt;- c("Anakin Skywalker", "Luke Skywalker")
print(strsplit(skywalkers, split = " "))
skywalkers &lt;- c("Skywalker, Anakin", "Skywalker, Luke")
print(strsplit(skywalkers, split = ", "))</code></pre><p><code>paste()</code> &#20989;&#25976;&#33021;&#22816;&#23559;&#22810;&#20491;&#25991;&#23383;&#21521;&#37327;&#36899;&#32080;&#36215;&#20358;&#28858;&#19968;&#20491;&#25991;&#23383;&#21521;&#37327;&#65292;&#20351;&#29992; <code>sep</code> &#21443;&#25976;&#21487;&#20197;&#25351;&#23450;&#36899;&#32080;&#36215;&#20358;&#20197;&#24460;&#35201;&#20351;&#29992;&#20160;&#40636;&#20998;&#38548;&#31526;&#34399;&#65292;&#38928;&#35373;&#26159;&#20197;&#19968;&#20491;&#31354;&#26684;&#20358;&#36899;&#32080;&#12290;</p><pre><code>luke &lt;- "Luke"
skywalker &lt;- "Skywalker"
print(paste(luke, skywalker))</code></pre><p><code>paste0()</code> &#20989;&#25976;&#33287; <code>paste()</code> &#20989;&#25976;&#20316;&#29992;&#30456;&#21516;&#65292;&#21482;&#26159;&#25913;&#28858;&#38928;&#35373;&#20197;&#31354;&#23383;&#20018;&#36899;&#32080;&#12290;</p><pre><code>sky &lt;- "Sky"
walker &lt;- "walker"
print(paste0(sky, walker))</code></pre><p><code>trimws()</code> &#20989;&#25976;&#33021;&#22816;&#23559;&#25991;&#23383;&#21521;&#37327;&#20013;&#22810;&#39192;&#31354;&#26684;&#21034;&#38500;&#25976;&#65292;&#25152;&#35586;&#30340;&#22810;&#39192;&#31354;&#26684;&#25351;&#30340;&#26159;&#20986;&#29694;&#22312;&#25991;&#23383;&#24038;&#37002;&#30340;&#31354;&#26684;&#65288;leading blanks&#65289;&#25110;&#20986;&#29694;&#22312;&#25991;&#23383;&#21491;&#37002;&#30340;&#31354;&#26684;&#65288;trailing blanks&#65289;&#65292;&#33267;&#26044;&#20986;&#29694;&#22312;&#25991;&#23383;&#20043;&#38291;&#30340;&#31354;&#26684;&#65292;&#30001;&#26044;&#22810;&#25976;&#35486;&#35328;&#21477;&#23376;&#30340;&#32068;&#25104;&#37117;&#32722;&#24931;&#20197;&#31354;&#26684;&#21312;&#38548;&#21934;&#23383;&#65292;&#20006;&#19981;&#31639;&#26159;&#22810;&#39192;&#31354;&#26684;&#65288;&#20687;&#26159; Luke Skywalker &#21517;&#23383;&#33287;&#22995;&#27663;&#20043;&#38291;&#23384;&#22312;&#30340;&#31354;&#26684;&#65289;&#12290;&#21152;&#20837; <code>which = "left"</code> &#21443;&#25976;&#21487;&#20197;&#25351;&#23450;&#21034;&#38500;&#24038;&#37002;&#22810;&#39192;&#31354;&#26684;&#12289; <code>which = "right"</code> &#21443;&#25976;&#21487;&#20197;&#25351;&#23450;&#21034;&#38500;&#21491;&#37002;&#22810;&#39192;&#31354;&#26684;&#65292;&#38928;&#35373; <code>which = "both"</code> &#21363;&#21034;&#38500;&#24038;&#37002;&#33287;&#21491;&#37002;&#22810;&#39192;&#31354;&#26684;&#12290;</p><pre><code>luke &lt;- "   Luke Skywalker   "
print(trimws(luke))
print(trimws(luke, which = "left"))
print(trimws(luke, which = "right"))</code></pre><h2>&#25551;&#36848;&#32113;&#35336;&#20989;&#25976;</h2><p>&#25551;&#36848;&#32113;&#35336;&#20989;&#25976;&#21487;&#20197;&#37341;&#23565;&#25976;&#20540;&#21521;&#37327;&#20570;&#25688;&#35201;&#65292;&#24120;&#29992;&#30340;&#26377;&#65306;</p><ul><li><p><code>mean()</code></p></li><li><p><code>sd()</code></p></li><li><p><code>median()</code></p></li><li><p><code>range()</code></p></li><li><p><code>sum()</code></p></li><li><p><code>max()</code></p></li><li><p><code>min()</code></p></li></ul><p><code>mean()</code> &#20989;&#25976;&#33021;&#22816;&#23559;&#36664;&#20837;&#25976;&#20540;&#21521;&#37327;&#24179;&#22343;&#20540;&#22238;&#20659;&#12290;</p><pre><code>a_vector &lt;- 1:100
print(mean(a_vector))</code></pre><p><code>sd()</code> &#20989;&#25976;&#33021;&#22816;&#23559;&#36664;&#20837;&#25976;&#20540;&#21521;&#37327;&#27161;&#28310;&#24046;&#22238;&#20659;&#65292;R &#35486;&#35328;&#20013;&#30340; <code>sd()</code> &#20989;&#25976;&#23450;&#32681;&#28858;&#27171;&#26412;&#27161;&#28310;&#24046;&#65292;&#22312;&#35336;&#31639;&#20844;&#24335;&#20013;&#20998;&#27597;&#20351;&#29992;&#30340;&#26159; <code>n &#8212; 1</code></p><pre><code>a_vector &lt;- 1:100
print(sd(a_vector))</code></pre><p><code>median()</code> &#20989;&#25976;&#33021;&#22816;&#23559;&#36664;&#20837;&#25976;&#20540;&#21521;&#37327;&#20013;&#20301;&#25976;&#22238;&#20659;&#12290;</p><pre><code>a_vector &lt;- 1:100
print(median(a_vector))</code></pre><p><code>range()</code> &#20989;&#25976;&#33021;&#22816;&#23559;&#36664;&#20837;&#25976;&#20540;&#21521;&#37327;&#20013;&#26368;&#23567;&#20540;&#33287;&#26368;&#22823;&#20540;&#22238;&#20659;&#12290;</p><pre><code>a_vector &lt;- 1:100
print(range(a_vector))</code></pre><p><code>sum()</code> &#20989;&#25976;&#33021;&#22816;&#23559;&#36664;&#20837;&#25976;&#20540;&#21521;&#37327;&#20013;&#25152;&#26377;&#25976;&#20540;&#21152;&#32317;&#22238;&#20659;&#12290;</p><pre><code>a_vector &lt;- 1:100
print(sum(a_vector))</code></pre><p><code>max()</code> &#20989;&#25976;&#33021;&#22816;&#23559;&#36664;&#20837;&#25976;&#20540;&#21521;&#37327;&#20013;&#26368;&#22823;&#20540;&#22238;&#20659;&#12290;</p><pre><code>a_vector &lt;- 1:100
print(max(a_vector))</code></pre><p><code>min()</code> &#20989;&#25976;&#33021;&#22816;&#23559;&#36664;&#20837;&#25976;&#20540;&#21521;&#37327;&#20013;&#26368;&#23567;&#20540;&#22238;&#20659;&#12290;</p><pre><code>a_vector &lt;- 1:100
print(min(a_vector))</code></pre><p>&#25551;&#36848;&#32113;&#35336;&#20989;&#25976;&#37117;&#26377;&#19968;&#20491;&#20849;&#21516;&#30340;&#21443;&#25976; <code>na.rm</code> &#33021;&#22816;&#23559;&#36986;&#28431;&#20540;&#21521;&#37327; <code>NA</code> &#25490;&#38500;&#65292;&#22914;&#26524;&#36664;&#20837;&#24118;&#26377;&#36986;&#28431;&#20540;&#21521;&#37327;&#65292;&#24517;&#38920;&#35201;&#25351;&#23450; <code>na.rm = TRUE</code> &#25165;&#33021;&#22816;&#22238;&#20659;&#31572;&#26696;&#65288; <code>na.rm</code> &#38928;&#35373;&#28858; <code>FALSE</code> &#12290;&#65289;</p><pre><code>a_vector &lt;- 1:100
a_vector &lt;- c(a_vector, NA) # combine a NA
print(min(a_vector))
print(min(a_vector, na.rm = TRUE))</code></pre><p>&#22312;&#35469;&#35672; R &#35486;&#35328;&#24120;&#35211;&#30340;&#31995;&#32113;&#21151;&#33021;&#20989;&#25976;&#12289;&#25976;&#20540;&#21521;&#37327;&#20989;&#25976;&#12289;&#25991;&#23383;&#21521;&#37327;&#20989;&#25976;&#33287;&#25551;&#36848;&#32113;&#35336;&#20989;&#25976;&#20043;&#24460;&#65292;&#26412;&#31687;&#25991;&#31456;&#20358;&#21040;&#23614;&#32882;&#65292;&#24076;&#26395;&#24744;&#20063;&#21644;&#25105;&#19968;&#27171;&#26399;&#24453;&#19979;&#19968;&#31687;&#25991;&#31456;&#12290;</p><p>&#23565;&#26044;&#36889;&#31687;&#25991;&#31456;&#26377;&#20160;&#40636;&#24819;&#27861;&#21602;&#65311;&#21916;&#27489;&#128571;&#12289;&#30041;&#35328;&#128587;&#8205;&#9794;&#65039;&#25110;&#32773;&#20998;&#20139;&#128588;</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://datainpoint.substack.com/p/week-twenty-nine-builtin-functions-in-r/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://datainpoint.substack.com/p/week-twenty-nine-builtin-functions-in-r/comments"><span>Leave a comment</span></a></p><h2>&#35336;&#30059;&#23416;&#21729;&#23560;&#21312;</h2>
      <p>
          <a href="https://datainpoint.substack.com/p/week-twenty-nine-builtin-functions-in-r">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[約維安計畫：R 語言的流程控制]]></title><description><![CDATA[&#20108;&#21313;&#20843;&#36913;]]></description><link>https://datainpoint.substack.com/p/week-twenty-eight-control-flow-in-r</link><guid isPermaLink="false">https://datainpoint.substack.com/p/week-twenty-eight-control-flow-in-r</guid><dc:creator><![CDATA[Yao-Jen Kuo]]></dc:creator><pubDate>Tue, 26 Apr 2022 13:00:45 GMT</pubDate><enclosure url="https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/47028226-0cb8-4ae3-be54-ba50fc3eceb5_480x270.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!SMSu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F588d1ab7-fbaf-47ca-93c5-7d7a67b01e8a_480x270.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SMSu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F588d1ab7-fbaf-47ca-93c5-7d7a67b01e8a_480x270.gif 424w, https://substackcdn.com/image/fetch/$s_!SMSu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F588d1ab7-fbaf-47ca-93c5-7d7a67b01e8a_480x270.gif 848w, https://substackcdn.com/image/fetch/$s_!SMSu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F588d1ab7-fbaf-47ca-93c5-7d7a67b01e8a_480x270.gif 1272w, https://substackcdn.com/image/fetch/$s_!SMSu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F588d1ab7-fbaf-47ca-93c5-7d7a67b01e8a_480x270.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SMSu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F588d1ab7-fbaf-47ca-93c5-7d7a67b01e8a_480x270.gif" width="480" height="270" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/588d1ab7-fbaf-47ca-93c5-7d7a67b01e8a_480x270.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:270,&quot;width&quot;:480,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:4895370,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!SMSu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F588d1ab7-fbaf-47ca-93c5-7d7a67b01e8a_480x270.gif 424w, https://substackcdn.com/image/fetch/$s_!SMSu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F588d1ab7-fbaf-47ca-93c5-7d7a67b01e8a_480x270.gif 848w, https://substackcdn.com/image/fetch/$s_!SMSu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F588d1ab7-fbaf-47ca-93c5-7d7a67b01e8a_480x270.gif 1272w, https://substackcdn.com/image/fetch/$s_!SMSu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F588d1ab7-fbaf-47ca-93c5-7d7a67b01e8a_480x270.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#20358;&#28304;&#65306;giphy.com</figcaption></figure></div><h2>&#20160;&#40636;&#26159;&#27969;&#31243;&#25511;&#21046;</h2><p>&#22810;&#25976;&#31243;&#24335;&#35486;&#35328;&#37117;&#26371;&#24478;&#31243;&#24335;&#30908;&#30340;&#31532;&#19968;&#21015;&#38283;&#22987;&#25353;&#29031;&#21015;&#65288;Row-wise&#65289;&#30340;&#38918;&#24207;&#24448;&#19979;&#35712;&#21462;&#20006;&#19988;&#22519;&#34892;&#65292;&#20294;&#26159;&#22312;&#26576;&#20123;&#24773;&#27841;&#19979;&#65292;&#25105;&#20497;&#26371;&#24076;&#26395;&#33021;&#22312;&#26576;&#20123;&#31243;&#24335;&#30908;&#21487;&#20197;&#20381;&#29031;&#38656;&#27714;&#19981;&#22519;&#34892;&#12289;&#22519;&#34892;&#25110;&#32773;&#22519;&#34892;&#22810;&#27425;&#65292;&#36889;&#26178;&#23601;&#21487;&#20197;&#36879;&#36942;&#27969;&#31243;&#25511;&#21046;&#30340;&#27231;&#21046;&#20358;&#28415;&#36275;&#36889;&#20123;&#24773;&#27841;&#12290;</p><p>&#27969;&#31243;&#25511;&#21046;&#25351;&#30340;&#26159;&#22312;&#31243;&#24335;&#22519;&#34892;&#26178;&#65292;&#33021;&#22816;&#20381;&#36084;&#26781;&#20214;&#20358;&#27770;&#23450;&#31243;&#24335;&#21312;&#22602;&#65288;Code blocks&#65289;&#20013;&#30340;&#25351;&#20196;&#12289;&#25944;&#36848;&#25110;&#32773;&#20989;&#25976;&#21628;&#21483;&#30340;&#22519;&#34892;&#27425;&#25976;&#65292;&#22312;&#26781;&#20214;&#28858;&#37007;&#36655;&#21521;&#37327; <code>FALSE</code> &#30340;&#26178;&#20505;&#65292;&#31243;&#24335;&#21312;&#22602;&#20013;&#30340;&#31243;&#24335;&#30908;&#22519;&#34892;&#27425;&#25976;&#28858; 0&#65288;&#19981;&#22519;&#34892;&#65289;&#65307;&#22312;&#26781;&#20214;&#28858;&#37007;&#36655;&#21521;&#37327; <code>TRUE</code> &#30340;&#26178;&#20505;&#65292;&#31243;&#24335;&#21312;&#22602;&#20013;&#30340;&#31243;&#24335;&#30908;&#22519;&#34892;&#27425;&#25976;&#22823;&#26044;&#31561;&#26044; 1&#12290;&#20855;&#39636;&#20358;&#35498;&#65292;&#27969;&#31243;&#25511;&#21046;&#26159;&#19968;&#31278;&#27231;&#21046;&#65292;&#36889;&#20491;&#27231;&#21046;&#33021;&#35731;&#19968;&#27573;&#25351;&#20196;&#22312;&#26576;&#20123;&#24773;&#27841;&#19979;&#19981;&#34987;&#22519;&#34892;&#12289;&#22312;&#26576;&#20123;&#24773;&#27841;&#19979;&#34987;&#22519;&#34892;&#19968;&#27425;&#25110;&#32773;&#22312;&#26576;&#20123;&#24773;&#27841;&#19979;&#34987;&#37325;&#35079;&#22519;&#34892;&#65292;R &#35486;&#35328;&#23526;&#29694;&#27969;&#31243;&#25511;&#21046;&#26377;&#19977;&#31278;&#26041;&#24335;&#65306;</p><ol><li><p>&#26781;&#20214;&#21028;&#26039;&#12290;</p></li><li><p>&#36852;&#22280;&#12290;</p></li><li><p>&#20363;&#22806;&#34389;&#29702;&#12290;</p></li></ol><p>&#20854;&#20013;&#65292;&#26781;&#20214;&#21028;&#26039;&#33021;&#22816;&#20351;&#29992; <code>if-else if-else</code> &#25944;&#36848;&#33287;&#37007;&#36655;&#21521;&#37327;&#23436;&#25104;&#65307;&#36852;&#22280;&#21063;&#26377;&#20841;&#31278;&#36984;&#25799;&#65292;&#19968;&#26159;&#20351;&#29992; <code>while</code> &#36852;&#22280;&#33287;&#37007;&#36655;&#21521;&#37327;&#65292;&#20108;&#26159;&#20351;&#29992; <code>for</code> &#36852;&#22280;&#33287;&#36039;&#26009;&#32080;&#27083;&#65307;&#20363;&#22806;&#34389;&#29702;&#33021;&#22816;&#20351;&#29992; <code>tryCatch()</code> &#20989;&#25976;&#23436;&#25104;&#12290;</p><h2>&#20160;&#40636;&#26159;&#21312;&#22602;</h2><p>&#21312;&#22602;&#65288;Code blocks&#65289;&#25351;&#30340;&#26159;&#23559;&#19968;&#31995;&#21015;&#30456;&#38364;&#30340;&#25944;&#36848;&#38598;&#21512;&#22312;&#19968;&#36215;&#30340;&#31243;&#24335;&#30908;&#32080;&#27083;&#65292;&#22312; R &#35486;&#35328;&#20013;&#65292;&#21312;&#22602;&#20351;&#29992;&#19968;&#23565;&#22823;&#25324;&#34399;&#65288;A curly-brace pair&#65289;&#23559;&#25944;&#36848;&#21253;&#35037;&#22312;&#35041;&#38754;&#24418;&#25104;&#21312;&#22602;&#12290;&#22312;&#21069;&#36848;&#19977;&#31278;&#39006;&#22411;&#30340;&#27969;&#31243;&#25511;&#21046;&#20013;&#65292;&#37117;&#26371;&#21033;&#29992;&#21312;&#22602;&#23559;&#25944;&#36848;&#20381;&#38468;&#32102;&#26781;&#20214;&#21028;&#26039;&#12289;&#36852;&#22280;&#33287;&#20363;&#22806;&#34389;&#29702;&#65292;&#22914;&#27492;&#19968;&#20358;&#23601;&#33021;&#22816;&#22312;&#26576;&#20123;&#24773;&#27841;&#19979;&#35731;&#21312;&#22602;&#20013;&#30340;&#31243;&#24335;&#19981;&#34987;&#22519;&#34892;&#12289;&#22519;&#34892;&#20677;&#19968;&#27425;&#25110;&#22519;&#34892;&#29305;&#23450;&#27425;&#25976;&#12290;</p><pre><code>function_name &lt;- function() {
  # code block attached to a function
}
if (CONDITION) {
  # code block attached to an if statement
}
while (CONDITION) {
  # code block attached to a while loop
}
for (element in data_structure) {
  # code block attached to a for loop
}</code></pre><h2>&#26781;&#20214;&#21028;&#26039;</h2><p>&#26781;&#20214;&#21028;&#26039;&#26159;&#20381;&#37007;&#36655;&#21521;&#37327;&#28858;&#20551; <code>FALSE</code> &#25110;&#30495; <code>TRUE</code> &#26178;&#65292;&#20358;&#27770;&#23450;&#26159;&#21542;&#22519;&#34892;&#19968;&#27573;&#20301;&#26044;&#26576;&#21312;&#22602;&#20839;&#30340;&#31243;&#24335;&#65292;&#36879;&#36942;&nbsp;<code>if-else if-else</code>&nbsp;&#25944;&#36848;&#21487;&#20197;&#26681;&#25818;&#25351;&#23450;&#26781;&#20214;&#26159;&#21542;&#25104;&#31435;&#65292;&#27770;&#23450;&#24460;&#32396;&#35201;&#22519;&#34892;&#30340;&#31243;&#24335;&#65292;&#20063;&#21487;&#20197;&#32068;&#21512;&#22810;&#20491;&nbsp;<code>if-else if-else</code>&nbsp;&#25944;&#36848;&#36914;&#34892;&#26356;&#35079;&#38620;&#30340;&#26781;&#20214;&#21028;&#26039;&#12290;</p><p>&#25105;&#20497;&#20351;&#29992;&#20445;&#30041;&#23383;&nbsp;<code>if</code>&nbsp;&#25645;&#37197;&#19968;&#20491;&#26781;&#20214;&#24418;&#25104;&#37007;&#36655;&#21521;&#37327;&#65292;&#23601;&#33021;&#22816;&#24314;&#31435;&#19968;&#20491; <code>if</code> &#25944;&#36848;&#65292;<code>if</code> &#25944;&#36848;&#33021;&#22816;&#35731;&#21312;&#22602;&#30340;&#22519;&#34892;&#33287;&#21542;&#20381;&#36084;&#26781;&#20214;&#30340;&#37007;&#36655;&#21521;&#37327;&#65292;&#22914;&#26524;&#26781;&#20214;&#28858;&nbsp;<code>TRUE</code>&nbsp;&#21063;&#22519;&#34892;&#20381;&#38468;&#22823;&#25324;&#34399;&#20839;&#30340;&#31243;&#24335;&#21312;&#22602;&#65307;&#33509;&#26781;&#20214;&#28858;&nbsp;<code>FALSE</code>&nbsp;&#21063;&#19981;&#22519;&#34892;&#20381;&#38468;&#22823;&#25324;&#34399;&#20839;&#30340;&#31243;&#24335;&#21312;&#22602;&#12290;</p><pre><code>if (CONDITION) {
  # code block attached to an if statement
}</code></pre><p><code>CONDITION</code> &#21487;&#20197;&#36879;&#36942;&#38364;&#20418;&#36939;&#31639;&#31526;&#25110;&#32773;&#37007;&#36655;&#36939;&#31639;&#31526;&#29983;&#25104;&#65292;&#20363;&#22914;&#21028;&#26039;&#36664;&#20837;&#25972;&#25976;&#26159;&#21542;&#28858;&#27491;&#12290;&#20677;&#26377;&#22312;&#36664;&#20837;&#28858;&#27491;&#25976;&#26178;&#26371;&#22519;&#34892;&#20381;&#38468;&#22823;&#25324;&#34399;&#20839;&#30340;&#31243;&#24335;&#21312;&#22602;&#65292;&#22240;&#27492;&#36664;&#20837;&#38646;&#25110;&#36000;&#25976;&#26178;&#20989;&#25976;&#30340;&#36664;&#20986;&#30342;&#28858; <code>NULL</code>&#12290;</p><pre><code>is_positive &lt;- function(x) {
  if (x &gt; 0) {
    return("Positive.")
  }
}
print(is_positive(1))
print(is_positive(0))
print(is_positive(-1))</code></pre><p>&#25105;&#20497;&#20351;&#29992;&#20445;&#30041;&#23383;&nbsp;<code>if</code>&nbsp;&#33287; <code>else if</code>&nbsp;&#25645;&#37197;&#21508;&#33258;&#30340;&#26781;&#20214;&#24314;&#31435;&#19968;&#20491; <code>if-else if</code> &#25944;&#36848;&#65292;&#22914;&#26524;&nbsp;<code>if</code>&nbsp;&#24460;&#38754;&#30340;&#26781;&#20214;&#28858;&nbsp;<code>TRUE</code>&nbsp;&#21063;&#22519;&#34892;&#20381;&#38468;&#20854;&#22823;&#25324;&#34399;&#20839;&#30340;&#31243;&#24335;&#21312;&#22602;&#65307;&#33509;&nbsp;<code>if</code>&nbsp;&#24460;&#38754;&#30340;&#26781;&#20214;&#28858;&nbsp;<code>FALSE</code>&nbsp;&#21063;&#36339;&#36942;&#35442;&#21312;&#22602;&#25913;&#28858;&#27298;&#35222;&nbsp;<code>else if</code>&nbsp;&#24460;&#38754;&#30340;&#26781;&#20214;&#65292;&#22914;&#26524;&#26159;&nbsp;<code>TRUE</code>&nbsp;&#23601;&#22519;&#34892;&#20381;&#38468;&#20854;&#22823;&#25324;&#34399;&#20839;&#30340;&#31243;&#24335;&#21312;&#22602;&#65307;&#33509;&nbsp;<code>else if</code>&nbsp;&#24460;&#38754;&#30340;&#26781;&#20214;&#28858;&nbsp;<code>False</code>&nbsp;&#21063;&#36339;&#36942;&#35442;&#21312;&#22602;&#12290;</p><pre><code>if (CONDITION) {
  # code block attached to if statement
} else if (CONDITION) {
  # code block attached to else if statement
}</code></pre><p><code>CONDITION</code> &#21487;&#20197;&#36879;&#36942;&#38364;&#20418;&#36939;&#31639;&#31526;&#25110;&#32773;&#37007;&#36655;&#36939;&#31639;&#31526;&#29983;&#25104;&#65292;&#20363;&#22914;&#21028;&#26039;&#36664;&#20837;&#25972;&#25976;&#26159;&#21542;&#28858;&#27491;&#12290;&#36889;&#26178;&#36664;&#20837;&#38646;&#25110;&#36000;&#25976;&#26178;&#20989;&#25976;&#30340;&#36664;&#20986;&#30342;&#28858; <code>&#8220;Nonpositive&#8220;</code>&#12290;</p><pre><code>is_positive &lt;- function(x) {
  if (x &gt; 0) {
    return("Positive.")
  } else {
    return("Nonpositive.")
  }
}
print(is_positive(1))
print(is_positive(0))
print(is_positive(-1))</code></pre><p>&#25105;&#20497;&#20351;&#29992;&#20445;&#30041;&#23383;&nbsp;<code>if</code>&nbsp;&#12289;<code>else</code>&nbsp;&#25645;&#37197;&#19968;&#20491;&#26781;&#20214;&#24314;&#31435;&#19968;&#20491; <code>if-else</code> &#25944;&#36848;&#65292;&#22914;&#26524;&nbsp;<code>if</code>&nbsp;&#24460;&#38754;&#30340;&#26781;&#20214;&#28858;&nbsp;<code>TRUE</code>&nbsp;&#21063;&#22519;&#34892;&#20381;&#38468;&#20854;&#22823;&#25324;&#34399;&#20839;&#30340;&#31243;&#24335;&#21312;&#22602;&#65307;&#33509;&nbsp;<code>if</code>&nbsp;&#24460;&#38754;&#30340;&#26781;&#20214;&#28858;&nbsp;<code>FALSE</code>&nbsp;&#21063;&#36339;&#36942;&#35442;&#21312;&#22602;&#25913;&#28858;&#22519;&#34892;&#20381;&#38468;&nbsp;<code>else</code>&nbsp;&#22823;&#25324;&#34399;&#20839;&#30340;&#31243;&#24335;&#21312;&#22602;&#12290;</p><pre><code>if (CONDITION) {
  # code block attached to if statement
} else {
  # code block attached to else statement
}</code></pre><p><code>CONDITION</code> &#21487;&#20197;&#36879;&#36942;&#38364;&#20418;&#36939;&#31639;&#31526;&#25110;&#32773;&#37007;&#36655;&#36939;&#31639;&#31526;&#29983;&#25104;&#65292;&#20363;&#22914;&#21028;&#26039;&#36664;&#20837;&#25972;&#25976;&#26159;&#21542;&#28858;&#27491;&#12290;</p><pre><code>is_positive &lt;- function(x) {
  if (x &gt; 0) {
    return("Positive.")
  } else {
    return("Nonpositive.")
  }
}
print(is_positive(1))
print(is_positive(0))
print(is_positive(-1))</code></pre><p>&#22312;&#21069;&#38754;&#30340;&#20363;&#23376;&#20013;&#65292;&#25105;&#20497;&#21487;&#20197;&#30475;&#21040;&#21516;&#27171;&#19968;&#20491;&#12300;&#21028;&#26039;&#36664;&#20837;&#25972;&#25976;&#26159;&#21542;&#28858;&#27491;&#12301;&#30340;&#20989;&#25976;&#65292;&#21487;&#20197;&#29992;&#19981;&#21516;&#30340;&#26781;&#20214;&#21028;&#26039;&#25944;&#36848;&#20358;&#23526;&#20316;&#65292;&#37027;&#40636;&#22312;&#25033;&#29992;&#24773;&#22659;&#19978;&#65292;&#35442;&#22914;&#20309;&#21312;&#21029;&#33287;&#25505;&#29992;&#65311;&#31777;&#21934;&#20358;&#35498;&#65292;&#25105;&#20497;&#21487;&#20197;&#34249;&#30001;&#21028;&#26039; <code>CONDITION</code> &#26159;&#21542;&#20114;&#26021;&#65288;Mutually exclusive&#65289;&#20358;&#27770;&#23450;&#12290;&#36889;&#20491;&#35498;&#27861;&#26159;&#20381;&#25818; <code>if</code> &#25944;&#36848;&#12289;<code>if-else if</code> &#33287; <code>if-else</code> &#25944;&#36848;&#30340;&#20027;&#35201;&#24046;&#21029;&#65292;&#30001;&#26044; <code>if-else if</code> &#33287; <code>if-else</code> &#25944;&#36848;&#30340;&#26781;&#20214;&#21028;&#26039;&#26159;&#26377;&#20808;&#24460;&#38918;&#24207;&#30340;&#65292;&#30070;&#21069;&#38754; <code>if</code> &#25944;&#36848;&#24471;&#21040;&#20102;&#37007;&#36655; <code>TRUE</code>&#65292;&#24847;&#21619;&#33879;&#24460;&#32396;&#30340; <code>else if</code> &#25110; <code>else</code> &#25944;&#36848;&#23601;&#28961;&#38364;&#32202;&#35201;&#20102;&#12290;&#31777;&#21934;&#20358;&#35498;&#65292;&#20551;&#22914;&#26781;&#20214;&#24444;&#27492;&#20043;&#38291;&#26159;&#20114;&#26021;&#30340;&#65292;&#26781;&#20214;&#21028;&#26039;&#24590;&#40636;&#23531;&#22823;&#27010;&#37117;&#27794;&#26377;&#21839;&#38988;&#65307;&#20294;&#21453;&#36942;&#20358;&#35498;&#65292;&#20551;&#22914;&#26781;&#20214;&#24444;&#27492;&#20043;&#38291;&#26159;&#12300;&#38750;&#20114;&#26021;&#12301;&#30340;&#35441;&#65292;&#21028;&#26039;&#30340;&#38918;&#24207;&#20197;&#21450; <code>if</code> &#25944;&#36848;&#12289;<code>if-else if</code> &#33287; <code>if-else</code> &#25944;&#36848;&#23601;&#26371;&#38656;&#35201;&#35641;&#24910;&#22320;&#36984;&#25799;&#12290;&#33289;&#20363;&#20358;&#35498;&#65292;&#25105;&#20497;&#20381;&#25818; <a href="https://en.wikipedia.org/wiki/Body_mass_index">https://en.wikipedia.org/wiki/Body_mass_index</a> &#23531;&#20316;&#19968;&#20491;&#20989;&#25976; <code>get_bmi_desc()</code> &#21487;&#20197;&#26681;&#25818;&#36664;&#20837;&#30340; BMI &#25976;&#20540;&#65292;&#32102;&#20104;&#36942;&#36629;&#12289;&#27491;&#24120;&#12289;&#36942;&#37325;&#25110;&#32933;&#32982;&#30340;&#25991;&#23383;&#36664;&#20986;&#65292;&#23559;&#22235;&#20491;&#26781;&#20214;&#23531;&#25104;&#20114;&#26021;&#30340;&#26684;&#24335;&#65306;</p><ol><li><p>&#36942;&#36629;&#65306;BMI &lt; 18.5&#12290;</p></li><li><p>&#27491;&#24120;&#65306;BMI &gt;= 18.5 and BMI &lt; 25&#12290;</p></li><li><p>&#36942;&#37325;&#65306;BMI &gt;= 25 and BMI &lt; 30&#12290;</p></li><li><p>&#32933;&#32982;&#65306;BMI &gt;= 30&#12290;</p></li></ol><p>&#22312;&#26781;&#20214;&#20114;&#26021;&#30340;&#29376;&#27841;&#19979;&#65292;&#24590;&#40636;&#23531;&#22823;&#27010;&#37117;&#27794;&#26377;&#21839;&#38988;&#12290;</p><pre><code>get_bmi_desc &lt;- function(bmi) {
  if (bmi &lt; 18.5){
    bmi_desc &lt;- "&#36942;&#36629;"
  } else if (bmi &gt;= 30) {
    bmi_desc &lt;- "&#32933;&#32982;"
  } else if (bmi &gt;= 25 &amp; bmi &lt; 30) {
    bmi_desc &lt;- "&#36942;&#37325;"
  } else if (bmi &gt;= 18.5 &amp; bmi &lt; 25) {
    bmi_desc &lt;- "&#27491;&#24120;"
  } 
  return(bmi_desc)
}   
print(get_bmi_desc(17))
print(get_bmi_desc(23))
print(get_bmi_desc(29))
print(get_bmi_desc(31))</code></pre><p>&#20294;&#36889;&#19981;&#34920;&#31034;&#26781;&#20214;&#21028;&#26039;&#23601;&#24517;&#38920;&#23559;&#26781;&#20214;&#37117;&#23531;&#25104;&#20114;&#26021;&#25165;&#21487;&#20197;&#65292;&#22312;&#36969;&#30070;&#38918;&#24207;&#33287;&#25944;&#36848;&#23433;&#25490;&#19979;&#65292;&#21363;&#20351;&#38750;&#20114;&#26021;&#20063;&#33021;&#36948;&#21040;&#27491;&#30906;&#21028;&#26039;&#32080;&#26524;&#12290;</p><pre><code>get_bmi_desc &lt;- function(bmi) {
  if (bmi &gt;= 30){
    bmi_desc &lt;- "&#32933;&#32982;"
  } else if (bmi &gt;= 25) {
    bmi_desc &lt;- "&#36942;&#37325;"
  } else if (bmi &gt;= 18.5) {
    bmi_desc &lt;- "&#27491;&#24120;"
  } else {
    bmi_desc &lt;- "&#36942;&#36629;"
  } 
  return(bmi_desc)
}   
print(get_bmi_desc(17))
print(get_bmi_desc(23))
print(get_bmi_desc(29))
print(get_bmi_desc(31))</code></pre><h2>&#36852;&#22280;</h2><p>&#36852;&#22280;&#26159;&#24120;&#35211;&#30340;&#27969;&#31243;&#25511;&#21046;&#20043;&#19968;&#65292;&#36889;&#26159;&#19968;&#31278;&#22312;&#21312;&#22602;&#20013;&#21482;&#20986;&#29694;&#19968;&#27425;&#12289;&#20294;&#21371;&#21487;&#33021;&#34987;&#36899;&#32396;&#22519;&#34892;&#22810;&#27425;&#30340;&#31243;&#24335;&#30908;&#32080;&#27083;&#65292;&#21312;&#22602;&#20013;&#30340;&#31243;&#24335;&#30908;&#26371;&#22519;&#34892;&#29305;&#23450;&#30340;&#27425;&#25976;&#12289;&#22519;&#34892;&#21040;&#29305;&#23450;&#26781;&#20214;&#25104;&#31435;&#26178;&#32080;&#26463;&#25110;&#32773;&#36208;&#35370;&#36039;&#26009;&#32080;&#27083;&#20013;&#30340;&#25152;&#26377;&#20839;&#23481;&#65292;&#36852;&#22280;&#33021;&#22816;&#29992;&#38283;&#22987;&#12289;&#32080;&#26463;&#33287;&#38291;&#38548;&#19977;&#20491;&#35201;&#32032;&#25551;&#36848;&#12290;</p><ul><li><p>start&#65306;&#36852;&#22280;&#30340;&#38283;&#22987;&#12290;</p></li><li><p>stop&#65306;&#36852;&#22280;&#30340;&#32080;&#26463;&#12290;</p></li><li><p>step&#65306;&#36852;&#22280;&#24478;&#36215;&#22987;&#21069;&#24448;&#32066;&#27490;&#30340;&#26041;&#27861;&#12290;</p></li></ul><p>&#25105;&#20497;&#21487;&#20197;&#20351;&#29992;&#20445;&#30041;&#23383; <code>while</code>&nbsp;&#33287;&#26781;&#20214;&#24314;&#31435;&#19968;&#20491; <code>while</code> &#36852;&#22280;&#21312;&#22602;&#65292;&#30070;&#26781;&#20214;&#28858;&nbsp;<code>TRUE</code>&nbsp;&#37325;&#35079;&#22519;&#34892;&#20381;&#38468;&#20854;&#22823;&#25324;&#34399;&#20839;&#30340;&#31243;&#24335;&#21312;&#22602;&#12290;</p><pre><code>i = 0 # start
while (CONDITION) { # stop
  # code block attached to while statement
  i &lt;- i + step
} </code></pre><p><code>CONDITION</code> &#21487;&#20197;&#36879;&#36942;&#38364;&#20418;&#36939;&#31639;&#31526;&#25110;&#32773;&#37007;&#36655;&#36939;&#31639;&#31526;&#29983;&#25104;&#65292;&#20363;&#22914;&#21360;&#20986;&#21069; &#8;n &#20491;&#22855;&#25976;&#12290;</p><pre><code>print_first_n_odds &lt;- function(n) {
  i &lt;- 1
  odds &lt;- c() # empty vector
  while (length(odds) &lt; n) {
    print(i)
    odds &lt;- c(odds, i)
    i &lt;- i + 2
  }
}
print_first_n_odds(5)</code></pre><p>&#25105;&#20497;&#21487;&#20197;&#20351;&#29992;&#20445;&#30041;&#23383; <code>for</code> &#33287;&#36039;&#26009;&#32080;&#27083;&#24314;&#31435;&#19968;&#20491; <code>for</code> &#36852;&#22280;&#21312;&#22602;&#65292;&#20381;&#38468;&#20854;&#22823;&#25324;&#34399;&#20839;&#30340;&#31243;&#24335;&#21312;&#22602;&#26371;&#37325;&#35079;&#22519;&#34892;&#65292;&#30452;&#21040;&#19968;&#32173;&#36039;&#26009;&#32080;&#27083;&#30340;&#25152;&#26377;&#20803;&#32032;&#37117;&#34987;&#36208;&#35370;&#23436;&#30050;&#12290;</p><pre><code>for (element in data_structure) { # start/stop/step
  # code block attached to for statement
}</code></pre><p>&#19968;&#32173;&#36039;&#26009;&#32080;&#27083;&#34987;&#23459;&#21578;&#23436;&#25104;&#30340;&#30070;&#19979;&#65292;&#36852;&#22280;&#30340;&#19977;&#35201;&#32032;&#23601;&#24050;&#32147;&#25551;&#36848;&#23436;&#30050;&#12290;</p><ul><li><p>start&nbsp;&#19968;&#32173;&#36039;&#26009;&#32080;&#27083;&#30340;&#31532;&#19968;&#38917;&#20803;&#32032;&#12290;</p></li><li><p>stop&nbsp;&#19968;&#32173;&#36039;&#26009;&#32080;&#27083;&#30340;&#26368;&#24460;&#19968;&#38917;&#20803;&#32032;&#12290;</p></li><li><p>step&nbsp;&#19968;&#32173;&#36039;&#26009;&#32080;&#27083;&#30340;&#36887;&#34399;&#21312;&#38548;&#12290;</p></li></ul><p>&#20363;&#22914;&#21360;&#20986;&#21069; &#8;n &#20491;&#22855;&#25976;&#12290;</p><pre><code>print_first_n_odds &lt;- function(n) {
  vector_to_be_iterated &lt;- seq(from = 1, by = 2, length.out = n)
  for (i in vector_to_be_iterated) {
    print(i)
  }
}
print_first_n_odds(5)</code></pre><p>&#22312;&#21069;&#38754;&#30340;&#20363;&#23376;&#20013;&#65292;&#25105;&#20497;&#21487;&#20197;&#30475;&#21040;&#21516;&#27171;&#19968;&#20491;&#12300;&#21360;&#20986;&#21069; &#8;n &#20491;&#22855;&#25976;&#12301;&#30340;&#20989;&#25976;&#65292;&#21487;&#20197;&#29992;&#19981;&#21516;&#30340;&#36852;&#22280;&#39006;&#22411;&#20358;&#23526;&#20316;&#65292;&#37027;&#40636;&#22312;&#25033;&#29992;&#24773;&#22659;&#19978;&#65292;&#35442;&#22914;&#20309;&#21312;&#21029;&#33287;&#25505;&#29992;&#65311;&#31777;&#21934;&#20358;&#35498;&#65292;&#25105;&#20497;&#21487;&#20197;&#34249;&#30001;&#21028;&#26039;&#21312;&#22602;&#31243;&#24335;&#12300;&#37325;&#35079;&#22519;&#34892;&#30340;&#27425;&#25976;&#26159;&#21542;&#24050;&#30693;&#12301;&#20358;&#27770;&#23450;&#65292;&#24050;&#30693;&#37325;&#35079;&#22519;&#34892;&#27425;&#25976;&#30340;&#24773;&#22659;&#21487;&#20197;&#29992;&#20219;&#24847;&#36852;&#22280;&#65292;&#26410;&#30693;&#37325;&#35079;&#22519;&#34892;&#27425;&#25976;&#30340;&#24773;&#22659;&#20677;&#33021;&#25505;&#29992; <code>while</code> &#36852;&#22280;&#12290;&#36889;&#20491;&#35498;&#27861;&#26159;&#20381;&#25818; <code>while</code> &#36852;&#22280;&#33287; <code>for</code> &#36852;&#22280;&#30340;&#20027;&#35201;&#24046;&#21029;&#65292;<code>while</code> &#22312;&#37325;&#35079;&#22519;&#34892;&#21312;&#22602;&#31243;&#24335;&#30340;&#26178;&#20505;&#65292;&#26371;&#22312; <code>CONDITION</code> &#28858; <code>FALSE</code> &#30340;&#26178;&#20505;&#32066;&#27490;&#65307;&#32780; <code>for</code> &#22312;&#37325;&#35079;&#22519;&#34892;&#21312;&#22602;&#31243;&#24335;&#30340;&#26178;&#20505;&#65292;&#26371;&#22312;&#19968;&#32173;&#36039;&#26009;&#32080;&#27083;&#20013;&#30340;&#20803;&#32032;&#29992;&#32580;&#26178;&#20505;&#32066;&#27490;&#12290;&#36889;&#34920;&#31034; <code>while</code> &#36852;&#22280;&#26681;&#25818;&#19968;&#20491;&#28858;&#37007;&#36655;&#21521;&#37327;&#30340;&#29289;&#20214;&#27770;&#23450;&#37325;&#35079;&#22519;&#34892;&#31243;&#24335;&#21312;&#22602;&#26159;&#21542;&#32066;&#27490;&#65307;<code>for</code> &#36852;&#22280;&#21063;&#26681;&#25818;&#19968;&#20491;&#24050;&#30693;&#20803;&#32032;&#25976;&#37327;&#30340;&#36039;&#26009;&#32080;&#27083;&#27770;&#23450;&#37325;&#35079;&#22519;&#34892;&#31243;&#24335;&#21312;&#22602;&#26159;&#21542;&#32066;&#27490;&#12290;</p><p>&#33289;&#20363;&#20358;&#35498;&#65292;&#23531;&#20316;&#19968;&#27573;&#12300;&#29468;&#29468;&#29468;&#25976;&#23383;&#12301;&#31243;&#24335;&#23601;&#26159;&#19968;&#20491;&#12300;&#26410;&#30693;&#37325;&#35079;&#22519;&#34892;&#27425;&#25976;&#12301;&#30340;&#24773;&#27841;&#65292;&#27794;&#26377;&#36774;&#27861;&#22312;&#19968;&#38283;&#22987;&#23601;&#24471;&#30693;&#38656;&#35201;&#29468;&#22810;&#23569;&#27425;&#25165;&#33021;&#32080;&#26463;&#12290;</p><pre><code>random_integer &lt;- sample.int(100, size = 1)
users_guess &lt;- readline()
number_of_guess &lt;- 1
while (as.integer(users_guess) != random_integer) {
  if (as.integer(users_guess) &lt; random_integer) {
    print("Too small, guess larger!")
  } else if (as.integer(users_guess) &gt; random_integer) {
    print("Too large, guess smaller!")
  }
  users_guess &lt;- readline()
  number_of_guess &lt;- number_of_guess + 1
}
sprintf("Correct! You guessed %s times for the answer %s!", number_of_guess, random_integer)</code></pre><p>&#22312; R &#35486;&#35328;&#20013;&#25152;&#35586;&#30340;&#19968;&#32173;&#36039;&#26009;&#32080;&#27083;&#26159;&#20219;&#24847;&#38263;&#24230;&#30340;&#21521;&#37327;&#65288;<code>vector</code>&#65289;&#12289;&#28165;&#21934;&#65288;<code>list</code>&#65289;&#65292;&#36889;&#20123;&#19968;&#32173;&#36039;&#26009;&#32080;&#27083;&#37117;&#33021;&#22816;&#30452;&#25509;&#25918;&#32622;&#22312; <code>for</code> &#36852;&#22280;&#20013;&#20351;&#29992;&#12290;</p><pre><code>print_all_elements &lt;- function(x) {
  for (element in x) {
    print(element)
  }
}
primes_vector &lt;- c(2, 3, 5, 7, 11)
primes_list &lt;- list(2, 3, 5, 7, 11)
print_all_elements(primes_vector)
print_all_elements(primes_list)</code></pre><p>&#20294;&#30697;&#38499;&#65288;<code>matrix</code>&#65289;&#33287;&#36039;&#26009;&#26694;&#65288;<code>data.frame</code>&#65289;&#26159;&#20855;&#26377;&#21015;&#65288;rows&#65289;&#33287;&#27396;&#65288;columns&#65289;&#30340;&#36039;&#26009;&#32080;&#27083;&#65292;&#35201;&#29305;&#21029;&#30041;&#24847;&#26159;&#24076;&#26395;&#36208;&#35370;&#21015;&#25110;&#32773;&#27396;&#12290;</p><pre><code>primes_matrix &lt;- matrix(c(1:5, c(2, 3, 5, 7, 11)), ncol = 2)
primes_dataframe = data.frame(primes_matrix)
# Iterating over a matrix's rows
for (i in 1:nrow(primes_matrix)) {
  print(primes_matrix[i, ])
}
# Iterating over a matrix's columns
for (j in 1:ncol(primes_matrix)) {
  print(primes_matrix[, j])
}
# Iterating over a data.frame's rows
for (i in 1:nrow(primes_dataframe)) {
  print(primes_dataframe[i, ])
}
# Iterating over a data.frame's columns
for (j in 1:ncol(primes_dataframe)) {
  print(primes_dataframe[, j])
}</code></pre><p>&#23559;&#27969;&#31243;&#25511;&#21046;&#30340;&#20841;&#20491;&#25216;&#24039;&#26781;&#20214;&#21028;&#26039;&#33287;&#36852;&#22280;&#21512;&#20341;&#20351;&#29992;&#26371;&#35731;&#25105;&#20497;&#30340;&#31243;&#24335;&#25776;&#23531;&#26356;&#26377;&#24392;&#24615;&#65292;&#20445;&#30041;&#23383;&nbsp;<code>break</code>&nbsp;&#33021;&#22816;&#35731;&#25105;&#20497;&#26044;&#36208;&#35370;&#30340;&#36942;&#31243;&#20013;&#22312;&#26781;&#20214;&#28858;&nbsp;<code>TRUE</code>&nbsp;&#30340;&#26178;&#20505;&#32066;&#27490;&#36852;&#22280;&#65292;&#33289;&#20363;&#20358;&#35498;&#30070;&#36208;&#35370;&#21040;&#38750;&#25976;&#20540;&#30340;&#26178;&#20505;&#32066;&#27490;&#36852;&#22280;&#12290;</p><pre><code>primes &lt;- list(2, 3, "5", 7, 11)
for (p in primes) {
  if (!is.numeric(p)) {
      break
  }
  print(p)
}</code></pre><p>&#20445;&#30041;&#23383;&nbsp;<code>next</code>&nbsp;&#33021;&#22816;&#35731;&#25105;&#20497;&#26044;&#36208;&#35370;&#30340;&#36942;&#31243;&#20013;&#22312;&#26781;&#20214;&#28858;&nbsp;<code>TRUE</code>&nbsp;&#30340;&#26178;&#20505;&#30053;&#36942;&#35442;&#20803;&#32032;&#20294;&#26159;&#32380;&#32396;&#23436;&#25104;&#36852;&#22280;&#65292;&#33289;&#20363;&#20358;&#35498;&#30070;&#36208;&#35370;&#21040;&#38750;&#25972;&#25976;&#30340;&#26178;&#20505;&#30053;&#36942;&#12290;</p><pre><code>primes &lt;- list(2, 3, "5", 7, 11)
for (p in primes) {
  if (!is.numeric(p)) {
      next
  }
  print(p)
}</code></pre><h2>&#20363;&#22806;&#34389;&#29702;</h2><p>&#20363;&#22806;&#34389;&#29702;&#25351;&#30340;&#26159;&#37341;&#23565;&#31243;&#24335;&#21312;&#22602;&#22519;&#34892;&#26178;&#25152;&#20986;&#29694;&#30340;&#20363;&#22806;&#65288;Exceptions&#65289;&#36914;&#34892;&#23565;&#25033;&#30340;&#34389;&#32622;&#65292;&#22312;&#22519;&#34892;&#31243;&#24335;&#21312;&#22602;&#26178;&#36973;&#36935;&#30340;&#20363;&#22806;&#24448;&#24448;&#26159;&#30001;&#26044;&#37679;&#35492;&#32780;&#24341;&#30332;&#65292;&#21253;&#21547;&#28961;&#25928;&#30340;&#29289;&#20214;&#21517;&#31281;&#12289;&#27284;&#26696;&#19981;&#23384;&#22312;&#25110;&#22411;&#21029;&#19981;&#27491;&#30906;&#31561;&#65292;&#20363;&#22806;&#34389;&#29702;&#23601;&#26159;&#22312;&#31243;&#24335;&#21312;&#22602;&#36973;&#36935;&#20363;&#22806;&#26178;&#33021;&#22816;&#31227;&#20132;&#25511;&#21046;&#27402;&#30340;&#19968;&#31278;&#27231;&#21046;&#12290;&#31777;&#21934;&#20358;&#35498;&#65292;&#20363;&#22806;&#34389;&#29702;&#23601;&#20687;&#26159;&#21478;&#19968;&#31278;&#39006;&#22411;&#30340;&#26781;&#20214;&#21028;&#26039;&#65292;&#21482;&#19981;&#36942;&#26781;&#20214;&#21028;&#26039;&#20506;&#36084;&#26781;&#20214;&#30340;&#24067;&#26519;&#20540;&#27770;&#23450;&#21738;&#20491;&#31243;&#24335;&#21312;&#22602;&#35201;&#34987;&#22519;&#34892;&#65292;&#32780;&#20363;&#22806;&#34389;&#29702;&#21063;&#26159;&#20381;&#36084;&#31243;&#24335;&#21312;&#22602;&#26159;&#21542;&#29986;&#29983;&#20102;&#37679;&#35492;&#20358;&#27770;&#23450;&#21738;&#20491;&#31243;&#24335;&#21312;&#22602;&#35201;&#34987;&#22519;&#34892;&#12290;&#25105;&#20497;&#21487;&#20197;&#20351;&#29992;&#20989;&#25976; <code>tryCatch()</code> &#34389;&#29702;&#20363;&#22806;&#12290;</p><pre><code>tryCatch(
  {#the "try" part },
  error = function(CONDITION) {
    message(CONDITION) # The original error message
    # Choose a return value in case of error
    return(NA)
  },
  warning = function(CONDITION) {
    message(CONDITION) # The original warning message
    # Choose a return value in case of warning
    return(NULL)
  },
  finally = function(CONDITION) {
    # Everything that should be executed at the end,
    # regardless of success, error, or warning.
  }
)</code></pre><p>&#20363;&#22914;&#23559;&#36664;&#20837;&#30340;&#20841;&#25976;&#30456;&#38500;&#65292;&#22312;&#36664;&#20837;&#20841;&#25976;&#20854;&#20013;&#19968;&#32773;&#28858;&#25991;&#23383;&#26178;&#20505;&#26371;&#29986;&#29983;&#37679;&#35492;&#12290;</p><pre><code>divide &lt;- function(a, b) {
  return(a/b)
}

print(divide(55, '11'))</code></pre><p>&#21152;&#20837;&#20363;&#22806;&#34389;&#29702; <code>tryCatch()</code> &#20989;&#25976;&#20197;&#21450; <code>error</code> &#21443;&#25976;&#34389;&#29702;&#36664;&#20837;&#25991;&#23383;&#26178;&#26371;&#29986;&#29983;&#30340;&#37679;&#35492;&#12290;</p><pre><code>divide &lt;- function(a, b) {
  out &lt;- tryCatch(
    {
     a/b
    },
    error = function(CONDITION) {
      message(CONDITION) # The original error message
      # Choose a return value in case of error
      return(NA)
    }
  )
}
print(divide(55, '11'))</code></pre><p>&#20363;&#22914;&#23559;&#36664;&#20837;&#36681;&#25563;&#28858;&#25976;&#20540;&#65292;&#22312;&#36664;&#20837;&#25991;&#23383;&#26178;&#20505;&#26371;&#29986;&#29983;&#35686;&#21578;&#12289;&#36664;&#20986; <code>NA</code>&#12290;</p><pre><code>print(as.numeric("Hello, world!"))</code></pre><p>&#21152;&#20837;&#20363;&#22806;&#34389;&#29702; <code>tryCatch()</code> &#20989;&#25976;&#20197;&#21450; <code>warning</code> &#21443;&#25976;&#34389;&#29702;&#36664;&#20837;&#25991;&#23383;&#26178;&#26371;&#29986;&#29983;&#30340;&#35686;&#21578;&#12289;&#25913;&#28858;&#36664;&#20986; NULL&#12290;</p><pre><code>as_numeric_try_catch &lt;- function(x) {
  out &lt;- tryCatch(
    {
      as.numeric(x)
    },
    warning = function(CONDITION) {
      message(CONDITION) # The original error message
      # Choose a return value in case of error
      return(NULL)
    }
  )
}
print(as_numeric_try_catch("Hello, world!"))</code></pre><p>&#22312;&#26296;&#35299; R &#35486;&#35328;&#26781;&#20214;&#21028;&#26039;&#12289;&#36852;&#22280;&#33287;&#20363;&#22806;&#34389;&#29702;&#36889;&#19977;&#31278;&#27969;&#31243;&#25511;&#21046;&#30340;&#27231;&#21046;&#20043;&#24460;&#65292;&#26412;&#31687;&#25991;&#31456;&#20358;&#21040;&#23614;&#32882;&#65292;&#24076;&#26395;&#24744;&#20063;&#21644;&#25105;&#19968;&#27171;&#26399;&#24453;&#19979;&#19968;&#31687;&#25991;&#31456;&#12290;</p><h2>&#24310;&#20280;&#38321;&#35712;</h2><ol><li><p><a href="https://adv-r.hadley.nz/control-flow.html">https://adv-r.hadley.nz/control-flow.html</a></p></li><li><p><a href="https://adv-r.hadley.nz/conditions.html">https://adv-r.hadley.nz/conditions.html</a></p></li></ol><p>&#23565;&#26044;&#36889;&#31687;&#25991;&#31456;&#26377;&#20160;&#40636;&#24819;&#27861;&#21602;&#65311;&#21916;&#27489;&#128571;&#12289;&#30041;&#35328;&#128587;&#8205;&#9794;&#65039;&#25110;&#32773;&#20998;&#20139;&#128588;</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://datainpoint.substack.com/p/week-twenty-eight-control-flow-in-r/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://datainpoint.substack.com/p/week-twenty-eight-control-flow-in-r/comments"><span>Leave a comment</span></a></p><h2>&#32004;&#32173;&#23433;&#35336;&#30059;&#23416;&#21729;&#23560;&#21312;</h2>
      <p>
          <a href="https://datainpoint.substack.com/p/week-twenty-eight-control-flow-in-r">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[約維安計畫：其他的資料結構]]></title><description><![CDATA[&#20108;&#21313;&#19971;&#36913;]]></description><link>https://datainpoint.substack.com/p/week-twenty-seven-other-data-structures</link><guid isPermaLink="false">https://datainpoint.substack.com/p/week-twenty-seven-other-data-structures</guid><dc:creator><![CDATA[Yao-Jen Kuo]]></dc:creator><pubDate>Fri, 15 Apr 2022 09:00:39 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!2Q4a!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F1fa9fbd6-b730-4002-acee-7bbc8c16da1a_480x480.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!2Q4a!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F1fa9fbd6-b730-4002-acee-7bbc8c16da1a_480x480.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2Q4a!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F1fa9fbd6-b730-4002-acee-7bbc8c16da1a_480x480.gif 424w, https://substackcdn.com/image/fetch/$s_!2Q4a!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F1fa9fbd6-b730-4002-acee-7bbc8c16da1a_480x480.gif 848w, https://substackcdn.com/image/fetch/$s_!2Q4a!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F1fa9fbd6-b730-4002-acee-7bbc8c16da1a_480x480.gif 1272w, https://substackcdn.com/image/fetch/$s_!2Q4a!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F1fa9fbd6-b730-4002-acee-7bbc8c16da1a_480x480.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!2Q4a!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F1fa9fbd6-b730-4002-acee-7bbc8c16da1a_480x480.gif" width="480" height="480" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/1fa9fbd6-b730-4002-acee-7bbc8c16da1a_480x480.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:480,&quot;width&quot;:480,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1983436,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!2Q4a!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F1fa9fbd6-b730-4002-acee-7bbc8c16da1a_480x480.gif 424w, https://substackcdn.com/image/fetch/$s_!2Q4a!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F1fa9fbd6-b730-4002-acee-7bbc8c16da1a_480x480.gif 848w, https://substackcdn.com/image/fetch/$s_!2Q4a!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F1fa9fbd6-b730-4002-acee-7bbc8c16da1a_480x480.gif 1272w, https://substackcdn.com/image/fetch/$s_!2Q4a!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F1fa9fbd6-b730-4002-acee-7bbc8c16da1a_480x480.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Source: giphy.com</figcaption></figure></div><p>&#25105;&#20497;&#22312;<a href="https://datainpoint.substack.com/p/week-twenty-five-creating-vectors">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;&#24314;&#31435;&#22522;&#26412;&#36039;&#26009;&#21934;&#20301;&#12300;&#21521;&#37327;&#12301;</a>&#20013;&#24050;&#32147;&#30693;&#36947; R &#35486;&#35328;&#30340;&#22522;&#26412;&#36039;&#26009;&#21934;&#20301;&#31281;&#20316;&#21521;&#37327;&#65288;<code>vector</code>&#65289;&#65292;&#36879;&#36942;&#32080;&#21512;&#22522;&#26412;&#36039;&#26009;&#21934;&#20301;&#65292;&#33021;&#22816;&#32068;&#25104;&#20854;&#20182;&#30340;&#36039;&#26009;&#32080;&#27083;&#65292;&#36889;&#20123;&#36039;&#26009;&#32080;&#27083;&#21253;&#21547;&#24392;&#24615;&#30340;&#23481;&#22120;&#65306;&#28165;&#21934;&#65288;<code>list</code>&#65289;&#12289;&#26377;&#38542;&#23652;&#36039;&#35338;&#30340;&#21521;&#37327;&#65306;&#22240;&#32032;&#21521;&#37327;&#65288;<code>factor</code>&#65289;&#12289;&#29694;&#20195;&#21270;&#34920;&#26684;&#65306;&#36039;&#26009;&#26694;&#65288;<code>data.frame</code>&#65289;&#12289;&#20108;&#32173;&#21521;&#37327;&#65306;&#30697;&#38499;&#65288;<code>matrix</code>&#65289;&#33287;&#22810;&#32173;&#21521;&#37327;&#65306;&#38499;&#21015;&#65288;<code>array</code>&#65289;&#12290;</p><h2>&#24392;&#24615;&#30340;&#23481;&#22120;&#65306;&#28165;&#21934;</h2><p>&#25105;&#20497;&#30446;&#21069;&#29087;&#24713;&#30340;&#21521;&#37327;&#21482;&#33021;&#34987;&#23459;&#21578;&#28858;&#21934;&#19968;&#39006;&#22411;&#65292;&#36889;&#26159;&#28858;&#20102;&#20803;&#32032;&#36939;&#31639;&#65288;Elementwise operation&#65289;&#32780;&#20276;&#38568;&#30340;&#20407;&#38480;&#65292;&#28982;&#32780;&#22312;&#25033;&#29992;&#19978;&#24456;&#22810;&#19981;&#21516;&#39006;&#22411;&#30340;&#36039;&#26009;&#26377;&#34987;&#20786;&#23384;&#22312;&#21516;&#19968;&#20491;&#29289;&#20214;&#20013;&#30340;&#38656;&#27714;&#65292;&#36889;&#26178;&#20505;&#25105;&#20497;&#23601;&#21487;&#20197;&#20351;&#29992; <code>list</code> &#36039;&#26009;&#32080;&#27083;&#20786;&#23384;&#20219;&#20309;&#39006;&#21029;&#12289;&#38263;&#24230;&#30340;&#21521;&#37327;&#65292;&#20351;&#29992; <code>list()</code> &#20989;&#25976;&#24314;&#31435;&#24392;&#24615;&#30340;&#23481;&#22120;&#65306;&#28165;&#21934;&#12290;</p><pre><code>a_R_list &lt;- list(
  c(FALSE, TRUE),
  c(55L, 66L, 56L, 5566L),
  c(55, 66, 56, 5566),
  c("Some", "random", "characters")
)
print(a_R_list)
print(class(a_R_list))</code></pre><p>&#28165;&#21934;&#24375;&#22823;&#30340;&#25910;&#32013;&#33021;&#21147;&#29992;&#25976;&#20491;&#38617;&#23652;&#20013;&#25324;&#34399; <code>[[]]</code> &#23559;&#21508;&#20491;&#21521;&#37327;&#20381;&#38918;&#24207;&#25918;&#20837;&#19968;&#20491;&#29289;&#20214;&#20043;&#20013;&#65292;&#36889;&#26178;&#20505;&#35201;&#36984;&#25799;&#35041;&#38754;&#30340;&#21521;&#37327;&#65292;&#23601;&#25913;&#20351;&#29992;&#38617;&#23652;&#20013;&#25324;&#34399; <code>[[&#32034;&#24341;&#20540;]]</code> &#65292;&#22312;&#36889;&#20491;&#28165;&#21934;&#20043;&#20013;&#65292;&#25105;&#20497;&#20786;&#23384;&#20102;&#22235;&#20491;&#19981;&#21516;&#39006;&#22411;&#30340;&#21521;&#37327;&#65292;&#20381;&#24207;&#26159;&#38263;&#24230; 2 &#30340;&#37007;&#36655;&#21521;&#37327;&#12289;&#38263;&#24230; 4 &#30340;&#25972;&#25976;&#21521;&#37327;&#12289;&#38263;&#24230; 4 &#30340;&#25976;&#20540;&#21521;&#37327;&#12289;&#38263;&#24230; 3 &#30340;&#25991;&#23383;&#21521;&#37327;&#65292;&#22312;&#28165;&#21934;&#20013;&#21508;&#20491;&#21521;&#37327;&#20381;&#28982;&#20445;&#26377;&#33258;&#24049;&#30340;&#39006;&#21029;&#12290;</p><pre><code>print(class(a_R_list[[1]]))
print(class(a_R_list[[2]]))
print(class(a_R_list[[3]]))
print(class(a_R_list[[4]]))</code></pre><p>&#24314;&#31435;&#28165;&#21934;&#30340;&#21516;&#26178;&#65292;&#22914;&#26524;&#25105;&#20497;&#26377;&#32102;&#20104;&#21521;&#37327;&#19968;&#20491;&#23565;&#25033;&#30340;&#37749;&#65288;Key&#65289;&#65292;&#21487;&#20197;&#22312;&#36984;&#25799;&#26178;&#25913;&#20351;&#29992; <code>[["key"]]</code> &#25110; <code>$key</code> &#65292;&#36889;&#26178;&#38754;&#23565;&#30340;&#26159;&#26377;&#21629;&#21517;&#30340;&#28165;&#21934;&#65288;Named list&#65289;&#12290;</p><pre><code>a_R_list &lt;- list(
  logicals = c(FALSE, TRUE),
  integers = c(55L, 66L, 56L, 5566L),
  numerics = c(55, 66, 56, 5566),
  characters = c("Some", "random", "characters")
)
# use [["key"]]
print(class(a_R_list[["logicals"]]))
print(class(a_R_list[["integers"]]))
print(class(a_R_list[["numerics"]]))
print(class(a_R_list[["characters"]]))
# use $key
print(class(a_R_list$logicals))
print(class(a_R_list$integers))
print(class(a_R_list$numerics))
print(class(a_R_list$characters))</code></pre><h2>&#26377;&#38542;&#23652;&#36039;&#35338;&#30340;&#21521;&#37327;&#65306;&#22240;&#32032;&#21521;&#37327;</h2><p>R &#35486;&#35328;&#37341;&#23565;&#25991;&#23383;&#21521;&#37327;&#26377;&#19968;&#20491;&#38989;&#22806;&#30340;&#36039;&#26009;&#32080;&#27083;&#31281;&#28858;&#22240;&#32032;&#21521;&#37327;&#65292;&#36889;&#26159;&#19968;&#31278;&#20855;&#26377;&#23652;&#32026;&#65288;Levels&#65289;&#36039;&#35338;&#30340;&#21521;&#37327;&#65292;&#25105;&#20497;&#21487;&#20197;&#20351;&#29992; <code>factor()</code> &#20989;&#25976;&#23559;&#19968;&#33324;&#30340;&#25991;&#23383;&#21521;&#37327;&#36681;&#25563;&#25104;&#22240;&#32032;&#21521;&#37327;&#12290;</p><pre><code>four_seasons &lt;- c("spring", "summer", "autumn", "winter")
print(class(four_seasons))
four_seasons_factor &lt;- factor(four_seasons)
print(class(four_seasons_factor))
print(four_seasons_factor)</code></pre><p>&#21360;&#20986;&#22240;&#32032;&#21521;&#37327;&#26178;&#26371;&#23559;&#23652;&#32026;&#30340;&#36039;&#35338;&#36664;&#20986;&#65292;&#38928;&#35373;&#30340;&#23652;&#32026;&#26159;&#20197;&#23383;&#27597;&#38918;&#24207;&#25490;&#21015;&#65288;&#30001; A &#25490;&#33267; Z&#65289;&#65292;&#32780;&#22312;&#36681;&#25563;&#28858;&#22240;&#32032;&#21521;&#37327;&#30340;&#20989;&#25976; <code>factor()</code> &#20043;&#20013;&#21033;&#29992; <code>ordered </code>&#33287; <code>levels</code> &#21443;&#25976;&#21487;&#20197;&#20381;&#29031;&#20351;&#29992;&#32773;&#30340;&#20559;&#22909;&#20570;&#25490;&#21015;&#12290;</p><pre><code>four_seasons_factor &lt;- factor(four_seasons, ordered = TRUE, levels = c("autumn", "spring", "winter", "summer"))
print(four_seasons_factor)</code></pre><h2>&#29694;&#20195;&#21270;&#34920;&#26684;&#65306;&#36039;&#26009;&#26694;</h2><p>&#36039;&#26009;&#26694;&#26159; R &#35486;&#35328;&#29992;&#20358;&#34389;&#29702;&#34920;&#26684;&#24335;&#36039;&#26009;&#65288;tabular data&#65289;&#30340;&#36039;&#26009;&#32080;&#27083;&#65292;&#23427;&#30340;&#22806;&#35264;&#20855;&#26377;&#21015;&#33287;&#27396;&#20841;&#20491;&#32173;&#24230;&#65292;&#20855;&#20633;&#21015;&#32034;&#24341;&#20540;&#33287;&#27396;&#32034;&#24341;&#20540;&#20358;&#25903;&#25588;&#20351;&#29992;&#32773;&#65292;&#20006;&#23481;&#35377;&#27599;&#19968;&#20491;&#27396;&#20301;&#65288;&#35722;&#25976;&#65289;&#20855;&#26377;&#33258;&#24049;&#30340;&#39006;&#21029;&#65292;&#20351;&#29992; R &#35486;&#35328;&#35712;&#21462;&#22806;&#37096;&#22320;&#34920;&#26684;&#24335;&#36039;&#26009;&#20063;&#26371;&#20197;&#36039;&#26009;&#26694;&#30340;&#32080;&#27083;&#20786;&#23384;&#65292;&#25105;&#20497;&#21487;&#20197;&#36939;&#29992; <code>data.frame()</code> &#20989;&#25976;&#21109;&#36896;&#36039;&#26009;&#26694;&#12290;</p><pre><code>titles &lt;- c("Batman Begins", "The Dark Knight", "The Dark Knight Rises")
release_years &lt;- c(2005, 2008, 2012)
imdb_ratings &lt;- c(8.2, 9.0, 8.4)
is_on_netflix &lt;- c(TRUE, FALSE, TRUE)
batman_trilogy &lt;- data.frame(title = titles, release_year = release_years, imdb_rating = imdb_ratings, is_on_netflix)
print(batman_trilogy)
print(class(batman_trilogy))</code></pre><p>&#25105;&#20497;&#20351;&#29992;&#35264;&#28204;&#20540;&#65288;observations&#65289;&#20358;&#31281;&#21628;&#36039;&#26009;&#26694;&#20013;&#27700;&#24179;&#26041;&#21521;&#30340;&#36039;&#26009;&#65292;&#20351;&#29992;&#35722;&#25976;&#65288;variables&#65289;&#20358;&#31281;&#21628;&#36039;&#26009;&#26694;&#20013;&#22402;&#30452;&#26041;&#21521;&#30340;&#36039;&#26009;&#65307;&#36039;&#26009;&#26694;&#33021;&#22816;&#20197; <code>[m, n]</code> &#20841;&#20491;&#32034;&#24341;&#20540;&#20358;&#25645;&#37197;&#36984;&#25799;&#65292;&#20854;&#20013; <code>m</code> &#26159;&#36039;&#26009;&#26694;&#30340;&#35264;&#28204;&#20540;&#20491;&#25976;&#65292; <code>n</code> &#26159;&#36039;&#26009;&#26694;&#30340;&#35722;&#25976;&#20491;&#25976;&#65292;&#19968;&#20491;&#36039;&#26009;&#26694;&#30340;&#22806;&#35264;&#21487;&#20197;&#31777;&#28500;&#22320;&#20197; (m, n) &#20358;&#25551;&#36848;&#65292;&#20363;&#22914;&#25163;&#21205;&#21109;&#24314;&#30340;&#36039;&#26009;&#26694; <code>batman_trilogy</code> &#22806;&#35264;&#28858; (3, 4)&#65292;&#36879;&#36942; dim() &#20989;&#25976;&#20358;&#26296;&#35299;&#36039;&#26009;&#26694;&#30340;&#22806;&#35264;&#12290;</p><pre><code>print(dim(batman_trilogy))
print(batman_trilogy[1, ])  # data in the 1st row
print(batman_trilogy[, 1])  # data in the 1st column
print(batman_trilogy[1, 1]) # data at (1, 1)</code></pre><p>&#36039;&#26009;&#26694;&#25903;&#25588;&#20351;&#29992;&#35722;&#25976;&#21517;&#31281;&#20358;&#36984;&#25799;&#65292;&#25105;&#20497;&#21487;&#20197;&#29992; <code>$variable_name&#12289;[["variable_name"]] </code>&#25110;&#32773; <code>[, "variable_name"]</code> &#36889;&#19977;&#31278;&#23531;&#27861;&#12290;</p><pre><code>print(batman_trilogy$title)
print(batman_trilogy[["title"]])
print(batman_trilogy[, "title"])</code></pre><p>&#25105;&#20497;&#21487;&#20197;&#36879;&#36942;&#37007;&#36655;&#21521;&#37327;&#20358;&#23565;&#36039;&#26009;&#26694;&#36914;&#34892;&#31721;&#36984;&#65292;&#35201;&#27880;&#24847;&#31721;&#36984;&#26159;&#37341;&#23565;&#35264;&#28204;&#20540;&#65288;&#27700;&#24179;&#26041;&#21521;&#65289;&#65292;&#25152;&#20197;&#35201;&#23559;&#37007;&#36655;&#21521;&#37327;&#25918;&#22312;&#36887;&#34399;&#21069;&#38754;&#65292;&#36887;&#34399;&#24460;&#38754;&#30041;&#31354;&#65288;&#20006;&#27794;&#26377;&#35201;&#36984;&#25799;&#35722;&#25976;&#12290;&#65289;</p><pre><code>print(batman_trilogy[batman_trilogy$is_on_netflix, ])</code></pre><p>&#36039;&#26009;&#26694;&#33021;&#21253;&#21547;&#22810;&#31278;&#21521;&#37327;&#39006;&#21029;&#65292;&#21487;&#20197;&#36879;&#36942; <code>str()</code> &#20989;&#25976;&#65288;structure &#30340;&#32302;&#23531;&#65289;&#27298;&#35222;&#32068;&#25104;&#36039;&#26009;&#26694;&#30340;&#21521;&#37327;&#39006;&#22411;&#12290;</p><pre><code>print(str(batman_trilogy))</code></pre><p>&#36039;&#26009;&#31185;&#23416;&#23478;&#33457;&#36027;&#24456;&#22810;&#30340;&#26178;&#38291;&#33287;&#36039;&#26009;&#26694;&#21608;&#26059;&#65292;&#24120;&#25033;&#29992;&#26044;&#25506;&#32034;&#36039;&#26009;&#26694;&#30340;&#20989;&#25976;&#20197;&#21450;&#36914;&#38542;&#30340;&#36039;&#26009;&#26694;&#25805;&#25511;&#25216;&#24039;&#26371;&#22312;&#24460;&#32396;&#35443;&#32048;&#25506;&#35342;&#12290;</p><h2>&#20108;&#32173;&#21521;&#37327;&#65306;&#30697;&#38499;</h2><p>&#30697;&#38499;&#33287;&#36039;&#26009;&#26694;&#30456;&#21516;&#26159;&#33021;&#22816;&#20786;&#23384;&#21015;&#65288;Row&#65289;&#33287;&#27396;&#65288;Column&#65289;&#30340;&#36039;&#26009;&#32080;&#27083;&#65292;&#22914;&#26524;&#23565;&#26044;&#20998;&#36776;&#34892;&#12289;&#21015;&#33287;&#27396;&#36889;&#20123;&#20013;&#25991;&#23383;&#26377;&#38556;&#31001;&#30340;&#35441;&#65292;&#25105;&#38750;&#24120;&#25512;&#34214;&#29992;&#33521;&#25991;&#20358;&#35352;&#25014;&#65306;<strong>Row</strong> &#25351;&#30340;&#26159;&#27700;&#24179;&#26041;&#21521;&#36039;&#26009;&#65292;<strong>Column</strong> &#25351;&#30340;&#26159;&#22402;&#30452;&#26041;&#21521;&#36039;&#26009;&#12290;&#36890;&#29992;&#30340;&#32722;&#24931;&#26159;<strong>&#20808;&#21015;&#24460;&#27396;</strong>&#65292;&#20551;&#22914;&#25105;&#20497;&#29694;&#22312;&#35201;&#24314;&#31435;&#19968;&#20491; (2, 3) &#30340;&#30697;&#38499;&#65292;&#24847;&#24605;&#23601;&#26159;&#20841;&#20491;&#27700;&#24179;&#26041;&#21521;&#25645;&#37197;&#19977;&#20491;&#22402;&#30452;&#26041;&#21521;&#30340;&#30697;&#38499;&#12290;&#20351;&#29992; <code>matrix()</code> &#20989;&#25976;&#20006;&#25351;&#23450;&#21443;&#25976; <code>nrow = 2</code> &#23559;&#21521;&#37327;&#36681;&#25563;&#25104;&#19968;&#20491; (2, 3) &#30340;&#30697;&#38499;&#65307;&#24448;&#24460;&#22914;&#26524;&#32893;&#21040;&#19968;&#20491;&#30697;&#38499;&#26159; (m, n) &#30340;&#22806;&#35264;&#65292;&#25105;&#20497;&#24515;&#20013;&#23601;&#26371;&#30693;&#36947;&#65292;&#36889;&#20491;&#30697;&#38499;&#20855;&#26377; m &#20491;&#27700;&#24179;&#26041;&#21521;&#36039;&#26009;&#65292;n &#20491;&#22402;&#30452;&#26041;&#21521;&#36039;&#26009;&#12290;</p><pre><code>a_R_matrix &lt;- matrix(c(5, 6, 55, 66, 56, 5566), nrow = 2)
print(a_R_matrix)
print(class(a_R_matrix))</code></pre><p>&#30697;&#38499;&#21516;&#27171;&#33021;&#22816;&#20197; <code>[]</code> &#25645;&#37197;&#32034;&#24341;&#20540;&#36984;&#20986;&#35041;&#38754;&#30340;&#35722;&#25976;&#65292;&#19981;&#36942;&#36319;&#21521;&#37327;&#19981;&#21516;&#30340;&#26159;&#29694;&#22312;&#26377;&#20841;&#20491;&#32173;&#24230;&#30340;&#32034;&#24341;&#20540;&#24517;&#38920;&#25351;&#23450;&#65292;&#25152;&#20197;&#35201;&#29992; <code>[m, n]</code> &#20841;&#20491;&#32034;&#24341;&#20540;&#20358;&#25645;&#37197;&#36984;&#25799;&#12290;</p><pre><code>print(a_R_matrix[2, 3]) # data at (2, 3)
print(a_R_matrix[2, ])  # data in the 2nd row
print(a_R_matrix[, 3])  # data in the 3rd column</code></pre><p>&#25105;&#20497;&#20063;&#21487;&#20197;&#36879;&#36942;<strong>&#37007;&#36655;&#21521;&#37327;</strong>&#20358;&#23565;&#30697;&#38499;&#36914;&#34892;&#31721;&#36984;&#12290;</p><pre><code>print(a_R_matrix[a_R_matrix &gt; 10])</code></pre><h2>&#22810;&#32173;&#21521;&#37327;&#65306;&#38499;&#21015;</h2><p>&#38499;&#21015;&#26159;&#21521;&#37327;&#12289;&#30697;&#38499;&#30340;&#22810;&#32173;&#24230;&#29256;&#26412;&#65292;&#38500;&#20102;&#21407;&#26377;&#30340;&#27700;&#24179;&#26041;&#21521;&#36039;&#26009;&#65288;Row&#65289;&#33287;&#22402;&#30452;&#26041;&#21521;&#36039;&#26009;&#65288;Column&#65289;&#25105;&#20497;&#21487;&#20197;&#20877;&#22810;&#25351;&#23450; n &#20491;&#32173;&#24230;&#65292;&#31777;&#21934;&#20358;&#35498;&#65292;&#23601;&#26159;&#22312;&#19968;&#20491;&#38499;&#21015;&#30340;&#29289;&#20214;&#20043;&#20013;&#65292;&#21487;&#20197;&#20801;&#35377;&#20786;&#23384;&#22810;&#20491;&#30697;&#38499;&#12290;&#33289;&#20363;&#20358;&#35498;&#25105;&#20497;&#23601;&#21487;&#20197;&#29992;&#38499;&#21015;&#23559; 1 &#21040; 24 &#36889; 24 &#20491;&#25976;&#23383;&#20786;&#23384;&#22312; 4 &#20491; (2, 2) &#30340;&#30697;&#38499;&#20043;&#20013;&#12290;</p><pre><code>a_R_array &lt;- array(1:24, dim = c(2, 3, 4))
print(a_R_array)
print(class(a_R_array))</code></pre><p>&#22240;&#28858;&#26377;&#20102;&#19977;&#20491;&#32173;&#24230;&#65292;&#25152;&#20197;&#22312;&#20351;&#29992;&#32034;&#24341;&#20540;&#36984;&#25799;&#26178;&#65292;&#23601;&#38656;&#35201;&#22686;&#21152;&#31532;&#19977;&#20491;&#32173;&#24230;&#30340;&#32034;&#24341;&#20540;&#12290;</p><pre><code>print(a_R_array[1, 2, 3]) # data at (1, 2, 3)
print(a_R_array[1, , 3])  # data in the 1st row of the 3rd matrix
print(a_R_array[, 2, 1])  # data in the 2nd column of the 1st matrix</code></pre><p>&#22312;&#21021;&#27493;&#26296;&#35299;&#22914;&#20309;&#22312; R &#35486;&#35328;&#20854;&#20182;&#30340;&#36039;&#26009;&#32080;&#27083;&#20043;&#24460;&#65292;&#26412;&#31687;&#25991;&#31456;&#20358;&#21040;&#23614;&#32882;&#65292;&#24076;&#26395;&#24744;&#20063;&#21644;&#25105;&#19968;&#27171;&#26399;&#24453;&#19979;&#19968;&#31687;&#25991;&#31456;&#12290;</p><h2>&#24310;&#20280;&#38321;&#35712;</h2><ol><li><p><a href="https://adv-r.hadley.nz/vectors-chap.html">https://adv-r.hadley.nz/vectors-chap.html</a></p></li><li><p><a href="https://r4ds.had.co.nz/factors.html">https://r4ds.had.co.nz/factors.html</a></p></li></ol><p>&#23565;&#26044;&#36889;&#31687;&#25991;&#31456;&#26377;&#20160;&#40636;&#24819;&#27861;&#21602;&#65311;&#21916;&#27489;&#128571;&#12289;&#30041;&#35328;&#128587;&#8205;&#9794;&#65039;&#25110;&#32773;&#20998;&#20139;&#128588;</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://datainpoint.substack.com/p/week-twenty-seven-other-data-structures/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://datainpoint.substack.com/p/week-twenty-seven-other-data-structures/comments"><span>Leave a comment</span></a></p>
      <p>
          <a href="https://datainpoint.substack.com/p/week-twenty-seven-other-data-structures">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[約維安計畫：操作基本資料單位「向量」 ]]></title><description><![CDATA[&#31532;&#20108;&#21313;&#20845;&#36913;]]></description><link>https://datainpoint.substack.com/p/week-twenty-six-manipulating-vectors</link><guid isPermaLink="false">https://datainpoint.substack.com/p/week-twenty-six-manipulating-vectors</guid><dc:creator><![CDATA[Yao-Jen Kuo]]></dc:creator><pubDate>Mon, 21 Mar 2022 07:00:35 GMT</pubDate><enclosure url="https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/cbb08e60-0349-4d50-b551-468071fefd64_480x268.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!gOKN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F1093ba3e-dc62-4954-b56b-bd3222387c67_480x268.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!gOKN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F1093ba3e-dc62-4954-b56b-bd3222387c67_480x268.gif 424w, https://substackcdn.com/image/fetch/$s_!gOKN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F1093ba3e-dc62-4954-b56b-bd3222387c67_480x268.gif 848w, https://substackcdn.com/image/fetch/$s_!gOKN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F1093ba3e-dc62-4954-b56b-bd3222387c67_480x268.gif 1272w, https://substackcdn.com/image/fetch/$s_!gOKN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F1093ba3e-dc62-4954-b56b-bd3222387c67_480x268.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!gOKN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F1093ba3e-dc62-4954-b56b-bd3222387c67_480x268.gif" width="480" height="268" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/1093ba3e-dc62-4954-b56b-bd3222387c67_480x268.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:268,&quot;width&quot;:480,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:4756358,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!gOKN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F1093ba3e-dc62-4954-b56b-bd3222387c67_480x268.gif 424w, https://substackcdn.com/image/fetch/$s_!gOKN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F1093ba3e-dc62-4954-b56b-bd3222387c67_480x268.gif 848w, https://substackcdn.com/image/fetch/$s_!gOKN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F1093ba3e-dc62-4954-b56b-bd3222387c67_480x268.gif 1272w, https://substackcdn.com/image/fetch/$s_!gOKN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F1093ba3e-dc62-4954-b56b-bd3222387c67_480x268.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#20358;&#28304;&#65306;giphy.com</figcaption></figure></div><h2>&#21521;&#37327;&#29305;&#24615;&#33287;&#25805;&#20316;&#26041;&#24335;</h2><p>&#25105;&#20497;&#22312;<a href="https://datainpoint.substack.com/p/week-twenty-five-creating-vectors">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;&#24314;&#31435;&#22522;&#26412;&#36039;&#26009;&#21934;&#20301;&#12300;&#21521;&#37327;&#12301;</a>&#26296;&#35299;&#20102;&#22914;&#20309;&#24314;&#31435;&#19981;&#21516;&#39006;&#22411;&#30340;&#21521;&#37327;&#65292;&#21253;&#21547;&#26377;&#65306;&#25976;&#20540;&#21521;&#37327;&#65288;<code>numeric</code>&#65289;&#12289;&#25972;&#25976;&#21521;&#37327;&#65288;<code>integer</code>&#65289;&#12289;&#25991;&#23383;&#21521;&#37327;&#65288;<code>character</code>&#65289;&#12289;&#37007;&#36655;&#21521;&#37327;&#65288;<code>logical</code>&#65289;&#12289;&#26085;&#26399;&#21521;&#37327;&#65288;<code>Date</code>&#65289;&#12289;&#26085;&#26399;&#26178;&#38291;&#21521;&#37327;&#65288;<code>POSIXct POSIXt</code>&#65289;&#33287;&#26410;&#23450;&#32681;&#20540;&#21521;&#37327;&#65288;<code>NA/NULL/NaN/-Inf/Inf</code>&#65289;&#12290;&#21521;&#37327;&#26377;&#35377;&#22810;&#30340;&#29305;&#24615;&#33287;&#25805;&#20316;&#26041;&#24335;&#20540;&#24471;&#25105;&#20497;&#30041;&#24847;&#21450;&#23416;&#32722;&#65292;&#21253;&#21547;&#26377;&#21521;&#37327;&#26159;&#21934;&#19968;&#39006;&#22411;&#30340;&#12289;&#21521;&#37327;&#21487;&#20197;&#21028;&#26039;&#21644;&#36681;&#25563;&#39006;&#22411;&#20197;&#21450;&#21521;&#37327;&#20803;&#32032;&#30340;&#35712;&#21462;&#12289;&#26356;&#26032;&#21644;&#21034;&#38500;&#31561;&#25805;&#20316;&#12290;</p><h2>&#21521;&#37327;&#26159;&#21934;&#19968;&#39006;&#22411;&#30340;</h2><p>&#21521;&#37327;&#21482;&#33021;&#34987;&#23459;&#21578;&#28858;&#21934;&#19968;&#39006;&#22411;&#65292;&#33289;&#20363;&#20358;&#35498;&#65292;&#22914;&#26524;&#25105;&#20497;&#20351;&#29992; <code>c()</code> &#20989;&#25976;&#23559;&#19981;&#21516;&#39006;&#22411;&#30340;&#21521;&#37327;&#21512;&#20341;&#65292;R &#35486;&#35328;&#26371;&#20381;&#29031;&#21521;&#19978;&#36681;&#22411;&#65288;Upcasting&#65289;&#35215;&#21063;&#65292;&#33258;&#21205;&#20006;&#19988;&#38577;&#24615;&#22320;&#29992;&#20854;&#20013;&#19968;&#20491;&#26356;&#31934;&#30906;&#30340;&#39006;&#22411;&#21435;&#35352;&#37636;&#21512;&#20341;&#24460;&#30340;&#21521;&#37327;&#39006;&#22411;&#12290;&#20363;&#22914;&#23559;&#37007;&#36655;&#21521;&#37327;&#33287;&#25972;&#25976;&#21521;&#37327;&#21512;&#20341;&#65292;&#26371;&#33258;&#21205;&#29554;&#24471;&#25972;&#25976;&#21521;&#37327;&#30340;&#32080;&#26524;&#65288;&#22240;&#28858;&#37007;&#36655; <code>FALSE</code> &#33287; <code>TRUE</code> &#33021;&#22816;&#20998;&#21029;&#29992;&#25972;&#25976; 0 &#33287; 1 &#21253;&#21547;&#65289;&#65307;&#25110;&#32773;&#23559;&#25972;&#25976;&#21521;&#37327;&#33287;&#25976;&#20540;&#21521;&#37327;&#21512;&#20341;&#65292;&#26371;&#33258;&#21205;&#29554;&#24471;&#25976;&#20540;&#21521;&#37327;&#30340;&#32080;&#26524;&#65288;&#22240;&#28858;&#25972;&#25976;&#33021;&#22816;&#29992;&#28014;&#40670;&#25976;&#21253;&#21547;&#65289;&#12290;</p><pre><code>favorite_integers &lt;- c(FALSE, TRUE, 7L, 24L, 25L)
favorite_numbers &lt;- c(7L, 24.0, 25.0)
print(class(favorite_integers))
print(class(favorite_numbers))</code></pre><h2>&#21521;&#37327;&#21487;&#20197;&#21028;&#26039;&#39006;&#22411;</h2><p>R &#35486;&#35328;&#37341;&#23565;&#21521;&#37327;&#39006;&#22411;&#30340;&#21028;&#26039;&#38500;&#20102;&#20351;&#29992; <code>class()</code> &#33287; <code>typeof()</code> &#20989;&#25976;&#33021;&#22816;&#30452;&#25130;&#20102;&#30070;&#22320;&#21578;&#35380;&#25105;&#20497;&#31572;&#26696;&#20197;&#22806;&#65292;&#20063;&#33021;&#22816;&#20351;&#29992;&#19968;&#31995;&#21015; <code>is.&#21521;&#37327;&#39006;&#22411;()</code> &#20989;&#25976;&#21028;&#26039;&#36664;&#20837;&#30340;&#21521;&#37327;&#26159;&#21542;&#28858;&#26576;&#20491;&#25351;&#23450;&#30340;&#21521;&#37327;&#39006;&#22411;&#12290;&#38500;&#20102;&#21028;&#26039;&#26085;&#26399;&#21521;&#37327;&#33287;&#26085;&#26399;&#26178;&#38291;&#21521;&#37327;&#35201;&#20351;&#29992;&#30340;&#26159; <code>inherits()</code> &#20989;&#25976;&#65292;&#20854;&#20182;&#37117;&#21487;&#20197;&#20351;&#29992; <code>is.&#21521;&#37327;&#39006;&#22411;()</code> &#31995;&#21015;&#20989;&#25976;&#21028;&#26039;&#12290;</p><ul><li><p><code>is.numeric()</code>&#65306;&#21028;&#26039;&#26159;&#21542;&#28858;&#25976;&#20540;&#21521;&#37327;&#12290;</p></li><li><p><code>is.integer()</code>&#65306;&#21028;&#26039;&#26159;&#21542;&#28858;&#25972;&#25976;&#21521;&#37327;&#12290;</p></li><li><p><code>is.character()</code>&#65306;&#21028;&#26039;&#26159;&#21542;&#28858;&#25991;&#23383;&#21521;&#37327;&#12290;</p></li><li><p><code>is.logical()</code>&#65306;&#21028;&#26039;&#26159;&#21542;&#28858;&#37007;&#36655;&#21521;&#37327;&#12290;</p></li><li><p><code>inherits(x, what = "Date")</code>&#65306;&#21028;&#26039;&#26159;&#21542;&#28858;&#26085;&#26399;&#21521;&#37327;&#12290;</p></li><li><p><code>inherits(x, what = "POSIXct")</code>&#65306;&#21028;&#26039;&#26159;&#21542;&#28858;&#26085;&#26399;&#26178;&#38291;&#21521;&#37327;&#12290;</p></li><li><p><code>is.na()</code>&#65306;&#21028;&#26039;&#26159;&#21542;&#28858;&#36986;&#28431;&#20540;&#21521;&#37327;&#12290;</p></li><li><p><code>is.null()</code>&#65306;&#21028;&#26039;&#26159;&#21542;&#28858;&#31354;&#20540;&#21521;&#37327;&#12290;</p></li><li><p><code>is.nan()</code>&#65306;&#21028;&#26039;&#26159;&#21542;&#28858;&#38750;&#25976;&#20540;&#21521;&#37327;&#12290;</p></li><li><p><code>is.infinite()</code>&#65306;&#21028;&#26039;&#26159;&#21542;&#28858;&#28961;&#38480;&#22823;&#25976;&#20540;&#21521;&#37327;&#12290;</p></li></ul><pre><code># is.numeric()
print(is.numeric(7))
print(is.numeric("7"))

# is.integer()
print(is.integer(7L))
print(is.integer(7))

# is.character()
print(is.character("FALSE"))
print(is.character(FALSE))

# is.logical()
print(is.logical(FALSE))
print(is.logical("FALSE"))

# inherits()
sys_date &lt;- Sys.Date()
sys_time &lt;- Sys.time()
print(inherits(sys_date, what = "Date"))
print(inherits("1970-01-01", what = "Date"))
print(inherits(sys_time, what = "POSIXct"))
print(inherits("1970-01-01 00:00:00", what = "POSIXct"))

# is.na()
print(is.na(NA))
print(is.na("NA"))

# is.null()
print(is.null(NULL))
print(is.null("NULL"))

# is.nan()
print(is.nan(NaN))
print(is.nan("NaN"))

# is.infinite()
print(is.infinite(Inf))
print(is.infinite("Inf"))</code></pre><h2>&#21521;&#37327;&#21487;&#20197;&#36681;&#25563;&#39006;&#22411;</h2><p>R &#35486;&#35328;&#37341;&#23565;&#21521;&#37327;&#39006;&#22411;&#30340;&#36681;&#25563;&#22816;&#20351;&#29992;&#19968;&#31995;&#21015; <code>as.&#21521;&#37327;&#39006;&#22411;()</code> &#20989;&#25976;&#36681;&#25563;&#36664;&#20837;&#30340;&#21521;&#37327;&#28858;&#26576;&#20491;&#25351;&#23450;&#30340;&#21521;&#37327;&#39006;&#22411;&#12290;</p><ul><li><p><code>as.numeric()</code>&#65306;&#36681;&#25563;&#28858;&#25976;&#20540;&#21521;&#37327;&#12290;</p></li><li><p><code>as.integer()</code>&#65306;&#36681;&#25563;&#28858;&#25972;&#25976;&#21521;&#37327;&#12290;</p></li><li><p><code>as.character()</code>&#65306;&#36681;&#25563;&#28858;&#25991;&#23383;&#21521;&#37327;&#12290;</p></li><li><p><code>as.logical()</code>&#65306;&#36681;&#25563;&#28858;&#37007;&#36655;&#21521;&#37327;&#12290;</p></li><li><p><code>as.Date()</code>&#65306;&#36681;&#25563;&#28858;&#26085;&#26399;&#21521;&#37327;&#12290;</p></li><li><p><code>as.POSIXct()</code>&#65306;&#36681;&#25563;&#28858;&#26085;&#26399;&#26178;&#38291;&#21521;&#37327;&#12290;</p></li><li><p><code>as.na()</code>&#65306;&#36681;&#25563;&#28858;&#36986;&#28431;&#20540;&#21521;&#37327;&#12290;</p></li><li><p><code>as.null()</code>&#65306;&#36681;&#25563;&#28858;&#31354;&#20540;&#21521;&#37327;&#12290;</p></li><li><p><code>as.nan()</code>&#65306;&#36681;&#25563;&#28858;&#38750;&#25976;&#20540;&#21521;&#37327;&#12290;</p></li><li><p><code>as.infinite()</code>&#65306;&#36681;&#25563;&#28858;&#28961;&#38480;&#22823;&#25976;&#20540;&#21521;&#37327;&#12290;</p></li></ul><p>&#20351;&#29992; <code>as.numeric()</code> &#20989;&#25976;&#36681;&#25563;&#36664;&#20837;&#28858;&#25976;&#20540;&#21521;&#37327;&#65292;&#36664;&#20837;&#25972;&#25976;&#21521;&#37327;&#12289;&#37007;&#36655;&#21521;&#37327;&#12289;&#26085;&#26399;&#21521;&#37327;&#25110;&#26085;&#26399;&#26178;&#38291;&#21521;&#37327;&#37117;&#33021;&#38918;&#21033;&#36681;&#25563;&#12290;</p><pre><code># as.numeric()
print(as.numeric(7L))
print(as.numeric(FALSE))
print(as.numeric(TRUE))
print(as.numeric(sys_date))
print(as.numeric(sys_time))</code></pre><p>&#20351;&#29992; <code>as.integer()</code> &#20989;&#25976;&#36681;&#25563;&#36664;&#20837;&#28858;&#25972;&#25976;&#21521;&#37327;&#65292;&#36664;&#20837;&#27794;&#26377;&#23567;&#25976;&#20301;&#25976;&#65288;&#25110;&#23567;&#25976;&#20301;&#25976;&#28858;&#38646;&#65289;&#30340;&#25976;&#20540;&#21521;&#37327;&#12289;&#37007;&#36655;&#20540;&#21521;&#37327;&#12289;&#26085;&#26399;&#21521;&#37327;&#25110;&#26085;&#26399;&#26178;&#38291;&#21521;&#37327;&#37117;&#33021;&#38918;&#21033;&#36681;&#25563;&#12290;</p><pre><code># as.integer()
print(as.integer(7.00))
print(as.integer(FALSE))
print(as.integer(TRUE))
print(as.integer(sys_date))
print(as.integer(sys_time))</code></pre><p>&#20351;&#29992; <code>as.logical()</code> &#20989;&#25976;&#36681;&#25563;&#36664;&#20837;&#28858;&#37007;&#36655;&#21521;&#37327;&#65292;&#36664;&#20837;&#25976;&#20540;&#25110;&#25972;&#25976;&#39006;&#22411;&#30340; 0 &#26371;&#36681;&#25563;&#25104;&#28858; <code>FALSE</code>&#65292;&#20854;&#20182;&#21063;&#19968;&#24459;&#36681;&#25563;&#28858; <code>TRUE</code>&#12290;&#36664;&#20837;&#25991;&#23383;&#21521;&#37327;&#30340; <code>"FALSE"</code>&#12289;<code>"False"</code> &#25110; <code>"false"</code> &#26371;&#36681;&#25563;&#28858; <code>FALSE</code>&#65292;&#21453;&#20043;&#36664;&#20837;&#25991;&#23383;&#21521;&#37327;&#30340; <code>"TRUE"</code>&#12289;<code>"True"</code> &#25110; <code>"true"</code> &#26371;&#36681;&#25563;&#28858; <code>TRUE</code>&#12290;</p><pre><code># as.logical()
print(as.logical(0))
print(as.logical(0L))
print(as.logical(1))
print(as.logical(1L))
print(as.logical(sys_date))
print(as.logical(sys_time))</code></pre><p>&#20351;&#29992; <code>as.character()</code> &#20989;&#25976;&#36681;&#25563;&#36664;&#20837;&#28858;&#25991;&#23383;&#21521;&#37327;&#65292;&#36664;&#20837;&#20219;&#24847;&#21521;&#37327;&#39006;&#22411;&#37117;&#33021;&#38918;&#21033;&#36681;&#25563;&#12290;</p><pre><code># as.character()
print(as.character(7))
print(as.character(7L))
print(as.character(FALSE))
print(as.character(TRUE))
print(as.character(sys_date))
print(as.character(sys_time))</code></pre><p>&#20351;&#29992; <code>as.Date()</code> &#20989;&#25976;&#36681;&#25563;&#36664;&#20837;&#28858;&#26085;&#26399;&#21521;&#37327;&#65292;&#25105;&#20497;&#21487;&#20197;&#36664;&#20837;&#25991;&#23383;&#21521;&#37327;&#35731; R &#35486;&#35328;&#36681;&#25563;&#25104;&#26085;&#26399;&#21521;&#37327;&#12290;</p><p>&#20351;&#29992; <code>as.POSIXct()</code> &#20989;&#25976;&#36681;&#25563;&#36664;&#20837;&#28858;&#26085;&#26399;&#26178;&#38291;&#21521;&#37327;&#65292;&#25105;&#20497;&#21487;&#20197;&#36664;&#20837;&#25991;&#23383;&#21521;&#37327;&#35731; R &#35486;&#35328;&#36681;&#25563;&#25104;&#26085;&#26399;&#26178;&#38291;&#21521;&#37327;&#65292;&#22914;&#26524;&#27794;&#26377;&#25351;&#23450;&#21443;&#25976; <code>tz</code> &#26371;&#38928;&#35373;&#20351;&#29992;&#38651;&#33126;&#30340;&#26178;&#21312;&#12290;</p><p>R &#35486;&#35328;&#38928;&#35373;&#21487;&#20197;&#35672;&#21029; <code>%Y-%m-%d %H:%M:%S </code>&#25110; <code>%Y/%m/%d %H:%M:%S</code> &#36889;&#20841;&#31278;&#26085;&#26399;&#26178;&#38291;&#30340;&#25991;&#23383;&#26684;&#24335;&#65292;&#22914;&#26524;&#26159;&#20854;&#20182;&#26684;&#24335;&#65292;&#24517;&#38920;&#35201;&#21152;&#20837; <code>format</code> &#21443;&#25976;&#21578;&#30693;&#34987;&#35352;&#37636;&#30340;&#26085;&#26399;&#26178;&#38291;&#26684;&#24335;&#28858;&#20309;&#65292;&#20989;&#25976;&#25165;&#33021;&#38918;&#21033;&#36681;&#25563;&#12290;&#24120;&#29992;&#30340;&#25991;&#23383;&#23565;&#25033;&#26085;&#26399;&#12289;&#26085;&#26399;&#26178;&#38291;&#26684;&#24335;&#26377;&#65306;</p><ul><li><p><code>%a</code>&#65306;&#32302;&#23531;&#30340;&#26143;&#26399;&#24190;&#65292;&#24478; Sun &#33267; Sat&#12290;</p></li><li><p><code>%A</code>&#65306;&#20840;&#31281;&#30340;&#26143;&#26399;&#24190;&#65292;&#24478; Sunday &#33267; Saturday&#12290;</p></li><li><p><code>%b</code>&#65306;&#32302;&#23531;&#30340;&#26376;&#20221;&#65292;&#24478; Jan &#33267; Dec&#12290;</p></li><li><p><code>%B</code>&#65306;&#20840;&#31281;&#30340;&#26376;&#20221;&#65292;&#24478; January &#33267; December&#12290;</p></li><li><p><code>%d</code>&#65306;&#26376;&#20221;&#20013;&#30340;&#31532;&#24190;&#22825;&#65292;&#24478; 01 &#33267; 31&#12290;</p></li><li><p><code>%m</code>&#65306;&#20197;&#20841;&#20301;&#25976;&#23383;&#34920;&#31034;&#30340;&#26376;&#20221;&#65292;&#24478; 01 &#33267; 12&#12290;</p></li><li><p><code>%Y</code>&#65306;&#20197;&#22235;&#20301;&#25976;&#23383;&#34920;&#31034;&#30340;&#35199;&#20803;&#24180;&#20221;&#65292;&#24478; 0 &#33267; 9999&#12290;</p></li><li><p><code>%H</code>&#65306;&#20197;&#20841;&#20301;&#25976;&#23383;&#34920;&#31034;&#30340;&#23567;&#26178;&#65292;&#24478; 00 &#33267; 23&#12290;</p></li><li><p><code>%M</code>&#65306;&#20197;&#20841;&#20301;&#25976;&#23383;&#34920;&#31034;&#30340;&#20998;&#37912;&#65292;&#24478; 00 &#33267; 59&#12290;</p></li><li><p><code>%S</code>&#65306;&#20197;&#20841;&#20301;&#25976;&#23383;&#34920;&#31034;&#30340;&#31186;&#25976;&#65292;&#24478; 00 &#33267; 59&#12290;</p></li></ul><pre><code># as.Date()
print(as.Date("1970-01-01"))
print(as.Date("1970/01/01"))
print(as.Date("01-01-1970", format = "%m-%d-%Y"))
print(as.Date("01/01/70", format = "%m/%d/%y"))

# as.POSIXct()
print(as.POSIXct("1970-01-01 00:00:00"))
print(as.POSIXct("01-01-1970 00:00:00", format = "%m-%d-%Y %H:%M:%S"))
print(as.POSIXct("1970-01-01 00:00:00", tz = "GMT"))</code></pre><h2>&#21521;&#37327;&#20803;&#32032;&#30340;&#35712;&#21462;</h2><p>&#23565;&#26044;&#38263;&#24230;&#36229;&#36942; 1 &#30340;&#21521;&#37327;&#25105;&#33021;&#22816;&#20351;&#29992;&#19977;&#31278;&#25216;&#24039;&#35712;&#21462;&#20854;&#20013;&#30340;&#20803;&#32032;&#65306;</p><ol><li><p>&#32034;&#24341;&#65288;Indexing&#65289;&#12290;</p></li><li><p>&#20999;&#21106;&#65288;Slicing&#65289;&#12290;</p></li><li><p>&#37007;&#36655;&#31721;&#36984;&#65288;Logical filtering&#65289;&#12290;</p></li></ol><p>&#21521;&#37327;&#20687;&#26159;&#26377;&#26684;&#23376;&#30340;&#25277;&#23644;&#65292;&#27599;&#20491;&#26684;&#23376;&#19978;&#38754;&#37117;&#26377;&#19968;&#20491;&#32034;&#24341;&#20540;&#65292;&#26041;&#20415; R &#35486;&#35328;&#25628;&#23563;&#25918;&#22312;&#35041;&#38957;&#30340;&#36039;&#26009;&#65292;&#36889;&#20491;&#32034;&#24341;&#20540;&#24478;&#24038;&#37002;&#30001; 1 &#36215;&#22987;&#35336;&#31639;&#12290;</p><pre><code># Indexing
four_seasons &lt;- c("spring", "summer", "autumn", "winter")
print(four_seasons[1])
print(four_seasons[2])
print(four_seasons[3])
print(four_seasons[4])</code></pre><p>&#30070;&#32034;&#24341;&#20540;&#26159;&#20197; <code>start:stop</code> &#24314;&#31435;&#30340;&#25976;&#20540;&#38291;&#36317;&#28858; 1 &#25976;&#20540;&#21521;&#37327;&#26178;&#65292;&#36889;&#27171;&#30340;&#25216;&#24039;&#23601;&#31281;&#28858;&#20999;&#21106;&#65288;Slicing&#65289;&#65292;&#24847;&#21363;&#21462;&#20986;&#19968;&#20491;&#21521;&#37327;&#20013;&#30340;&#26576;&#29255;&#27573;&#12290;</p><pre><code># Slicing
print(four_seasons[1:3])
print(four_seasons[2:4])</code></pre><p>&#20999;&#21106;&#20063;&#33021;&#29992; <code>c()</code> &#20989;&#25976;&#32080;&#21512;&#22810;&#20491;&#32034;&#24341;&#20540;&#20659;&#20837;&#65292;&#20063;&#21487;&#20197;&#25509;&#21463;&#36000;&#30340;&#32034;&#24341;&#20540;&#65292;&#34920;&#31034;&#25505;&#29992;&#36000;&#38754;&#34920;&#21015;&#26041;&#24335;&#35712;&#21462;&#20854;&#20013;&#30340;&#20803;&#32032;&#12290;</p><pre><code># Slicing
print(four_seasons[c(1, 3)])
print(four_seasons[c(2, 4)])
print(four_seasons[c(-2, -4)])
print(four_seasons[c(-1, -3)])</code></pre><p>&#38500;&#20102;&#20351;&#29992;&#32034;&#24341;&#25110;&#20999;&#21106;&#30340;&#25216;&#24039;&#65292;&#20134;&#21487;&#20197;&#23565;&#21521;&#37327;&#25033;&#29992;&#26781;&#20214;&#25944;&#36848;&#65288;Conditional statement&#65289;&#65292;&#36914;&#32780;&#29986;&#29983;&#37007;&#36655;&#21521;&#37327;&#20316;&#28858;&#23565;&#21407;&#21521;&#37327;&#31721;&#36984;&#30340;&#20381;&#25818;&#65292;&#26371;&#20445;&#30041;&#21028;&#26039;&#28858; <code>TRUE</code> &#20301;&#32622;&#30340;&#20803;&#32032;&#12290;</p><pre><code># Logical filtering
favorite_season &lt;- four_seasons == "winter"
print(favorite_season)
print(four_seasons[favorite_season])</code></pre><h2>&#21521;&#37327;&#20803;&#32032;&#30340;&#26356;&#26032;&#21644;&#21034;&#38500;</h2><p>&#36879;&#36942;&#32034;&#24341;&#65288;Indexing&#65289;&#33287; <code>&lt;-</code> &#20358;&#26356;&#26032;&#21644;&#21034;&#38500;&#21521;&#37327;&#20013;&#30340;&#20803;&#32032;&#12290;</p><pre><code># Update
four_seasons[3] &lt;- "fall"
print(four_seasons)

# Delete
three_seasons &lt;- four_seasons[-3]
print(three_seasons)</code></pre><p>&#22312;&#21021;&#27493;&#26296;&#35299;&#22914;&#20309;&#22312; R &#35486;&#35328;&#25805;&#20316;&#22522;&#26412;&#36039;&#26009;&#21934;&#20301;&#12300;&#21521;&#37327;&#12301;&#20043;&#24460;&#65292;&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;&#25805;&#20316;&#22522;&#26412;&#36039;&#26009;&#21934;&#20301;&#12300;&#21521;&#37327;&#12301;&#20358;&#21040;&#23614;&#32882;&#65292;&#24076;&#26395;&#24744;&#20063;&#21644;&#25105;&#19968;&#27171;&#26399;&#24453;&#19979;&#19968;&#31687;&#25991;&#31456;&#12290;</p><h2>&#24310;&#20280;&#38321;&#35712;</h2><ol><li><p><a href="https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/strptime">https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/strptime</a></p></li><li><p><a href="https://r4ds.had.co.nz/vectors.html">https://r4ds.had.co.nz/vectors.html</a></p></li><li><p><a href="https://adv-r.hadley.nz/vectors-chap.html">https://adv-r.hadley.nz/vectors-chap.html</a></p></li></ol><p>&#23565;&#26044;&#36889;&#31687;&#25991;&#31456;&#26377;&#20160;&#40636;&#24819;&#27861;&#21602;&#65311;&#21916;&#27489;&#128571;&#12289;&#30041;&#35328;&#128587;&#8205;&#9794;&#65039;&#25110;&#32773;&#20998;&#20139;&#128588;</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://datainpoint.substack.com/p/week-twenty-six-manipulating-vectors/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://datainpoint.substack.com/p/week-twenty-six-manipulating-vectors/comments"><span>Leave a comment</span></a></p>
      <p>
          <a href="https://datainpoint.substack.com/p/week-twenty-six-manipulating-vectors">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[約維安計畫：建立基本資料單位「向量」]]></title><description><![CDATA[&#31532;&#20108;&#21313;&#20116;&#36913;]]></description><link>https://datainpoint.substack.com/p/week-twenty-five-creating-vectors</link><guid isPermaLink="false">https://datainpoint.substack.com/p/week-twenty-five-creating-vectors</guid><dc:creator><![CDATA[Yao-Jen Kuo]]></dc:creator><pubDate>Sat, 26 Feb 2022 13:48:04 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!roy3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4975e28e-6310-4005-aed6-5f9e8b8ee8c5_480x480.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!roy3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4975e28e-6310-4005-aed6-5f9e8b8ee8c5_480x480.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!roy3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4975e28e-6310-4005-aed6-5f9e8b8ee8c5_480x480.gif 424w, https://substackcdn.com/image/fetch/$s_!roy3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4975e28e-6310-4005-aed6-5f9e8b8ee8c5_480x480.gif 848w, https://substackcdn.com/image/fetch/$s_!roy3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4975e28e-6310-4005-aed6-5f9e8b8ee8c5_480x480.gif 1272w, https://substackcdn.com/image/fetch/$s_!roy3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4975e28e-6310-4005-aed6-5f9e8b8ee8c5_480x480.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!roy3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4975e28e-6310-4005-aed6-5f9e8b8ee8c5_480x480.gif" width="480" height="480" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/4975e28e-6310-4005-aed6-5f9e8b8ee8c5_480x480.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:480,&quot;width&quot;:480,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:429755,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!roy3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4975e28e-6310-4005-aed6-5f9e8b8ee8c5_480x480.gif 424w, https://substackcdn.com/image/fetch/$s_!roy3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4975e28e-6310-4005-aed6-5f9e8b8ee8c5_480x480.gif 848w, https://substackcdn.com/image/fetch/$s_!roy3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4975e28e-6310-4005-aed6-5f9e8b8ee8c5_480x480.gif 1272w, https://substackcdn.com/image/fetch/$s_!roy3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4975e28e-6310-4005-aed6-5f9e8b8ee8c5_480x480.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#20358;&#28304;&#65306;giphy.com</figcaption></figure></div><h2>&#22522;&#26412;&#36039;&#26009;&#21934;&#20301;</h2><p>R &#35486;&#35328;&#30340;&#22522;&#26412;&#36039;&#26009;&#21934;&#20301;&#65288;Building block&#65289;&#31281;&#20316;<strong>&#21521;&#37327;&#65288;Vector&#65289;</strong>&#65292;&#36889;&#19968;&#40670;&#33287;&#22823;&#22810;&#25976;&#24291;&#27867;&#29992;&#36884;&#31243;&#24335;&#35486;&#35328;&#65288;General-purposed programming languages&#65289;&#20363;&#22914;&#65306;C/C++ &#35486;&#35328;&#12289;Java &#35486;&#35328;&#25110; Python &#26377;&#26126;&#39023;&#30340;&#24046;&#30064;&#12290;&#31777;&#21934;&#20358;&#35498;&#65292;&#22312; R &#35486;&#35328;&#23526;&#36368;&#12300;&#21704;&#22217;&#19990;&#30028;&#12301;<code>print()</code> &#20989;&#25976;&#20854;&#20013;&#30340; <code>"Hello, World!"</code> &#23565; R &#35486;&#35328;&#20358;&#35498;&#23601;&#19981;&#26159;&#20197;&#32020;&#37327;&#65288;Scalar&#65289;&#20358;&#30475;&#24453;&#22905;&#65292;&#32780;&#26159;&#23559;&#20854;&#35222;&#20316;&#38263;&#24230; 1 &#30340;<strong>&#25991;&#23383;&#21521;&#37327;</strong>&#12290;</p><pre><code>hello_world &lt;- "Hello, World!"
print(hello_world)
print(class(hello_world))     # Check the class of hello_world
print(is.vector(hello_world)) # Check if hello_world is a vector or not
print(length(hello_world))    # Check the length of hello_world</code></pre><p>&#20197;&#21521;&#37327;&#20316;&#28858;&#22522;&#26412;&#36039;&#26009;&#21934;&#20301;&#30340;&#35373;&#23450;&#39636;&#29694;&#20102; R &#35486;&#35328;&#20316;&#28858;&#19968;&#20491;&#20197;&#36039;&#26009;&#20998;&#26512;&#28858;&#20027;&#36600;&#30340;&#31243;&#24335;&#35486;&#35328;&#29702;&#24565;&#65292;&#23565;&#22905;&#32780;&#35328;&#65292;&#20219;&#20309;&#36939;&#31639;&#37117;&#26159;&#20803;&#32032;&#25805;&#20316;&#65288;elementwise&#65289;&#12290;R &#35486;&#35328;&#20013;&#30340;&#21521;&#37327;&#26377;&#33879;&#19981;&#21516;&#30340;&#39006;&#22411;&#65292;&#21253;&#21547;&#26377;&#65306;&#25976;&#20540;&#21521;&#37327;&#65288;<code>numeric</code>&#65289;&#12289;&#25972;&#25976;&#21521;&#37327;&#65288;<code>integer</code>&#65289;&#12289;&#25991;&#23383;&#21521;&#37327;&#65288;<code>character</code>&#65289;&#12289;&#37007;&#36655;&#21521;&#37327;&#65288;<code>logical</code>&#65289;&#12289;&#26085;&#26399;&#21521;&#37327;&#65288;<code>Date</code>&#65289;&#12289;&#26085;&#26399;&#26178;&#38291;&#21521;&#37327;&#65288;<code>POSIXct POSIXt</code>&#65289;&#33287;&#26410;&#23450;&#32681;&#20540;&#65288;<code>NA/NULL/NaN/-Inf/Inf</code>&#65289;&#12290;</p><h2>&#22914;&#20309;&#24314;&#31435;&#21521;&#37327;</h2><p>&#24314;&#31435;&#38263;&#24230;&#28858; 1 &#30340;&#21521;&#37327;&#38750;&#24120;&#31777;&#21934;&#65292;&#21482;&#38656;&#35201;&#29992; <code>&lt;-</code> &#23559;&#19981;&#21516;&#39006;&#22411;&#30340;&#36039;&#26009;&#25351;&#27966;&#32102;&#29289;&#20214;&#21517;&#31281;&#21363;&#21487;&#65292;&#20351;&#29992;&#32773;&#19981;&#38656;&#35201;&#33258;&#24049;&#21435;&#29468;&#28204;&#21521;&#37327;&#39006;&#22411;&#65292;&#32780;&#26159;&#20351;&#29992;&#20989;&#25976; <code>class()</code> &#25110;&#32773; <code>typeof()</code> &#35731; R &#35486;&#35328;&#21578;&#35380;&#25105;&#20497;&#35442;&#29289;&#20214;&#26159;&#20160;&#40636;&#39006;&#22411;&#30340;&#21521;&#37327;&#65292;&#20006;&#19988;&#20351;&#29992; <code>length()</code> &#20989;&#25976;&#27298;&#35222;&#21521;&#37327;&#38263;&#24230;&#12290;</p><pre><code>hello_world &lt;- "Hello, World!"
print(hello_world)
print(class(hello_world))  # Check the class of hello_world
print(typeof(hello_world)) # Check the type of hello_world
print(length(hello_world)) # Check the length of hello_world</code></pre><h2>&#24314;&#31435;&#25976;&#20540;&#21521;&#37327;</h2><p>&#22914;&#26524;&#24819;&#35201;&#24314;&#31435;&#38263;&#24230;&#22823;&#26044; 1 &#30340;&#21521;&#37327;&#65292;&#26368;&#24120;&#20351;&#29992;&#30340;&#26041;&#27861;&#26159;&#21033;&#29992; <code>c()</code> &#20989;&#25976;&#65288;combine &#30340;&#31777;&#31281;&#65289;&#65292;&#22312; <code>c()</code> &#20989;&#25976;&#20013;&#21487;&#20197;&#23559;&#22810;&#31558;&#36039;&#26009;&#20197;&#36887;&#34399;&#20998;&#38548;&#20197;&#19968;&#20491;&#29289;&#20214;&#21517;&#31281;&#21443;&#29031;&#12290;</p><pre><code>favorite_numbers &lt;- c(7, 24, 25)
print(favorite_numbers)
print(class(favorite_numbers))  # Check the class of favorite_numbers
print(typeof(favorite_numbers)) # Check the type of favorite_numbers
print(length(favorite_numbers)) # Check the length of favorite_numbers</code></pre><p><code>rep()</code> &#20989;&#25976;&#65288;replicate &#30340;&#31777;&#31281;&#65289;&#21487;&#20197;&#29983;&#25104;&#21253;&#21547;&#37325;&#35079;&#36039;&#26009;&#30340;&#21521;&#37327;&#65292;&#20854;&#20013; <code>times</code> &#21443;&#25976;&#21487;&#20197;&#25351;&#23450;&#21521;&#37327;&#20013;&#35201;&#26377;&#24190;&#20491;&#37325;&#35079;&#20540;&#12290;</p><pre><code>lucky_sevens &lt;- rep(7, times = 3)
print(lucky_sevens)
print(length(lucky_sevens)) # Check the length of lucky_sevens</code></pre><p>&#24314;&#31435;&#38263;&#24230;&#22823;&#26044; 1 &#30340;&#25976;&#20540;&#21521;&#37327;&#38500;&#20102;&#22914;&#21069;&#36848;&#19968;&#33324;&#20351;&#29992; <code>c()</code> &#20989;&#25976;&#25110;&#32773; <code>rep()</code> &#20989;&#25976;&#65292;&#20134;&#21487;&#20197;&#21628;&#21483; <code>seq()</code> &#20989;&#25976;&#65288;sequence &#30340;&#31777;&#31281;&#65289;&#25110; <code>:</code> &#31526;&#34399;&#24314;&#31435;&#20855;&#26377;&#25976;&#21015;&#29305;&#24615;&#30340;&#25976;&#20540;&#21521;&#37327;&#12290; <code>seq()</code> &#20989;&#25976;&#21487;&#20197;&#29983;&#25104;&#31561;&#24046;&#25976;&#21015;&#65292;&#20854;&#20013; <code>from</code> &#21443;&#25976;&#25351;&#23450;&#25976;&#21015;&#30340;&#36215;&#22987;&#20540;&#65292;<code>to</code> &#21443;&#25976;&#25351;&#23450;&#25976;&#21015;&#30340;&#32066;&#27490;&#20540;&#65292;<code>by</code> &#21443;&#25976;&#25351;&#23450;&#25976;&#20540;&#30340;&#38291;&#36317;&#12290;</p><pre><code>print(seq(from = 7, to = 63, by = 7))</code></pre><p>&#22914;&#26524;&#21934;&#32020;&#26159;&#35201;&#29983;&#25104;&#25976;&#20540;&#38291;&#36317;&#28858; 1 &#30340;&#25976;&#20540;&#21521;&#37327;&#65292;&#29992; <code>:</code> &#31526;&#34399;&#26356;&#24555;&#25463;&#12290;</p><pre><code>print(1:20)</code></pre><p>&#19981;&#35542;&#36664;&#20837;&#25976;&#23383;&#24118;&#26377;&#25110;&#19981;&#24118;&#26377;&#23567;&#25976;&#40670;&#65292;R &#35486;&#35328;&#38928;&#35373;&#37117;&#20197;&#25976;&#20540;&#21521;&#37327;&#65288;<code>numeric</code>&#65289;&#20786;&#23384;&#12290;</p><pre><code>favorite_numbers &lt;- c(2.718, 3.14, 7, 24, 25)
print(favorite_numbers)
print(class(favorite_numbers))  # Check the class of favorite_numbers
print(typeof(favorite_numbers)) # Check the type of favorite_numbers</code></pre><h2>&#24314;&#31435;&#25972;&#25976;&#21521;&#37327;</h2><p>&#36664;&#20837;&#25972;&#25976;&#20006;&#21152;&#20837;&#22823;&#23531;&#33521;&#25991;&#23383;&#27597; L &#20316;&#35387;&#35352;&#65292;R &#35486;&#35328;&#23601;&#26371;&#25913;&#20786;&#23384;&#28858;&#25972;&#25976;&#21521;&#37327;&#65288;<code>integer</code>&#65289;&#12290;</p><pre><code>favorite_integers &lt;- c(7L, 24L, 25L)
print(favorite_integers)
print(class(favorite_integers))  # Check the class of favorite_integers
print(typeof(favorite_integers)) # Check the type of favorite_integers</code></pre><p>&#33509;&#22312;&#24118;&#26377;&#24517;&#35201;&#23567;&#25976;&#20301;&#25976;&#30340;&#25976;&#23383;&#24460;&#21152;&#19978;&#22823;&#23531;&#33521;&#25991;&#23383;&#27597; <code>L</code> &#35387;&#35352; R &#35486;&#35328;&#23559;&#24573;&#30053;&#25972;&#25976;&#21521;&#37327;&#30340;&#35387;&#35352;&#25913;&#20197;&#25976;&#20540;&#21521;&#37327;&#20786;&#23384;&#12290;</p><pre><code>favorite_numbers &lt;- c(2.718L, 3.14L)
print(favorite_numbers)
print(class(favorite_numbers))  # Check the class of favorite_numbers
print(typeof(favorite_numbers)) # Check the type of favorite_numbers</code></pre><h2>&#24314;&#31435;&#25991;&#23383;&#21521;&#37327;</h2><p>&#22312; R &#35486;&#35328;&#20013;&#25105;&#20497;&#21487;&#20197;&#20351;&#29992;&#25104;&#38617;&#30340;&#21934;&#24341;&#34399; <code>''</code> &#25110;&#25104;&#23565;&#30340;&#38617;&#24341;&#34399; <code>""</code> &#20358;&#24314;&#31435;&#25991;&#23383;&#21521;&#37327;&#65288;<code>character</code>&#65289;&#65292;&#22810;&#25976;&#30340;&#26178;&#20505;&#20351;&#29992;&#21934;&#24341;&#34399;&#25110;&#32773;&#38617;&#24341;&#34399;&#19981;&#26371;&#26377;&#20219;&#20309;&#20998;&#21029;&#12290;</p><pre><code>hellos &lt;- c("Hello, World!", 'Hello, R!')
print(hellos)
print(class(hellos))  # Check the class of hellos
print(typeof(hellos)) # Check the type of hellos</code></pre><p>&#20294;&#26159;&#22312;&#37096;&#20998;&#24773;&#22659;&#20013;&#65292;&#20351;&#29992;&#25104;&#38617;&#30340;&#21934;&#24341;&#34399;&#25110;&#25104;&#23565;&#30340;&#38617;&#24341;&#34399;&#27161;&#35387;&#25991;&#23383;&#21521;&#37327;&#26159;&#26377;&#24046;&#21029;&#30340;&#65292;&#20687;&#26159;&#22312;&#33521;&#25991;&#21477;&#23376;&#20013;&#32147;&#24120;&#20986;&#29694;&#30340;&#38750;&#25104;&#38617;&#21934;&#24341;&#34399;&#65288;Apostrophe&#65289;&#20197;&#21450;&#29992;&#20316;&#22066;&#35575;&#24375;&#35519;&#30340;&#31354;&#27683;&#38617;&#24341;&#34399;&#65288;air-quotes&#65289;&#65292;&#30070;&#25991;&#23383;&#21521;&#37327;&#20013;&#30340;&#20839;&#23481;&#26377;&#20986;&#29694;&#36889;&#20123;&#20803;&#20214;&#26178;&#22914;&#26524;&#27794;&#26377;&#29305;&#21029;&#38364;&#27880;&#65292;&#23459;&#21578;&#30340;&#30070;&#19979;&#23601;&#26371;&#29986;&#29983;&#37679;&#35492;&#12290;</p><pre><code># Error: unexpected symbol
mcdonalds &lt;- 'I'm lovin it'
shaq &lt;- 'Shaquille O'Neal'
ross_geller_said &lt;- "Let's put aside the fact that you "accidentally" pick up my grandmother's ring."</code></pre><p>&#36889;&#26178;&#20505;&#25105;&#20497;&#21487;&#20197;&#20351;&#29992;&#36339;&#33067;&#23383;&#20803;&#21453;&#26012;&#32218; <code>\</code> &#20358;&#23436;&#25104;&#23459;&#21578;&#25110;&#32773;&#20351;&#29992;&#19981;&#21516;&#27171;&#24335;&#30340;&#24341;&#34399;&#12290;</p><pre><code>mcdonalds &lt;- 'I\'m lovin it'
shaq &lt;- 'Shaquille O\'Neal'
ross_geller_said &lt;- "Let's put aside the fact that you \"accidentally\" pick up my grandmother's ring."</code></pre><h2><strong>&#24314;&#31435;&#37007;&#36655;&#21521;&#37327;</strong></h2><p>&#30070;&#25105;&#20497;&#36914;&#34892;<strong>&#21028;&#26039;&#26781;&#20214;</strong>&#25110;&#32773;<strong>&#36039;&#26009;&#31721;&#36984;</strong>&#30340;&#26178;&#20505;&#26371;&#38656;&#35201;&#20208;&#36084;&#37007;&#36655;&#21521;&#37327;&#65288;<code>logical</code>&#65289;&#65292;&#37007;&#36655;&#21521;&#37327;&#21482;&#26377; <code>FALSE</code> &#33287; <code>TRUE</code> &#36889;&#20841;&#20491;&#20540;&#65292;&#20134;&#21487;&#20197;&#31777;&#23531;&#28858; <code>F</code> &#33287; <code>T</code></p><pre><code>print(class(FALSE))
print(class(TRUE))
print(class(F))
print(class(T))</code></pre><p>&#36889;&#35041;&#29305;&#21029;&#25552;&#37266;&#19968;&#20491;&#35264;&#24565;&#65292;R &#35486;&#35328;&#23565;&#26044;&#33521;&#25991;&#30340;&#22823;&#23567;&#23531;&#26159;&#25935;&#24863;&#30340;&#65288;case-sensitive&#65289;&#65292;&#20687;&#26159; <code>TRUE</code> &#33287; <code>T</code> &#26371;&#34987;&#35672;&#21029;&#28858;&#37007;&#36655;&#21521;&#37327;&#65292;&#20294;&#26159; <code>True</code>&#12289;<code>true</code> &#25110;&#32773; <code>t</code> &#21063;&#26371;&#34987;&#35222;&#20316;&#29289;&#20214;&#20197;&#21450;&#20989;&#25976;&#21517;&#31281;&#12290;</p><h2>&#24314;&#31435;&#26085;&#26399;&#21521;&#37327;</h2><p>&#22312; R &#35486;&#35328;&#20013;&#26085;&#26399;&#21521;&#37327;&#65288;<code>Date</code>&#65289;&#30340;&#22806;&#35264;&#30475;&#36215;&#20358;&#36319;&#25991;&#23383;&#21521;&#37327;&#20006;&#27794;&#26377;&#20160;&#40636;&#24046;&#21029;&#65292;&#20294;&#26159;&#30070;&#25105;&#20497;&#19968;&#20294;&#23559;&#23427;&#20497;&#25918;&#20837; <code>class()</code> &#20989;&#25976;&#20013;&#27298;&#39511;&#65292;&#23601;&#26371;&#30332;&#29694;&#20006;&#19981;&#26159;&#25991;&#23383;&#21521;&#37327;&#65292;&#25509;&#19979;&#20358;&#20351;&#29992;&#30340; <code>Sys.Date()</code> &#26159;&#19981;&#38656;&#35201;&#21443;&#25976;&#23601;&#26371;&#36664;&#20986;&#38651;&#33126;&#31995;&#32113;&#26085;&#26399;&#21521;&#37327;&#30340;&#20989;&#25976;&#12290;</p><pre><code>sys_date &lt;- Sys.Date() # system date vector
print(sys_date)        # looks like a character
print(class(sys_date))</code></pre><p>R &#35486;&#35328;&#38928;&#35373;&#20197;&#35199;&#20803; 1970 &#24180; 1 &#26376; 1 &#26085;&#20316;&#28858; 0&#65292;&#22312;&#36889;&#19968;&#22825;&#20197;&#24460;&#30340;&#27599;&#22825;&#37117; +1 &#20358;&#35352;&#37636;&#65292;&#32780;&#36889;&#19968;&#22825;&#20197;&#21069;&#30340;&#27599;&#22825;&#37117; -1 &#20358;&#35352;&#37636;&#12290;&#25991;&#23383;&#21521;&#37327;&#33287;&#26085;&#26399;&#21521;&#37327;&#20841;&#32773;&#26368;&#22823;&#30340;&#20998;&#37326;&#65292;&#22312;&#26044;&#26085;&#26399;&#21521;&#37327;&#21487;&#20197;&#36914;&#34892;&#25976;&#20540;&#36939;&#31639;&#65292;&#32780;&#25991;&#23383;&#21521;&#37327;&#19981;&#34892;&#12290;</p><pre><code>print(sys_date - 1)
print(sys_date + 1)</code></pre><h2><strong>&#24314;&#31435;&#26085;&#26399;&#26178;&#38291;&#21521;&#37327;</strong></h2><p>&#22312; R &#35486;&#35328;&#20013;&#26085;&#26399;&#26178;&#38291;&#21521;&#37327;&#65288;<code>POSIXct POSIXt</code>&#65289;&#30340;&#22806;&#35264;&#30475;&#36215;&#20358;&#36319;&#25991;&#23383;&#21521;&#37327;&#21516;&#27171;&#20063;&#27794;&#26377;&#20160;&#40636;&#24046;&#21029;&#65292;&#20294;&#26159;&#25105;&#20497;&#19968;&#20294;&#23559;&#23427;&#20497;&#25918;&#20837; <code>class()</code> &#20989;&#25976;&#20013;&#27298;&#39511;&#65292;&#23601;&#26371;&#30332;&#29694;&#20006;&#19981;&#26159;&#25991;&#23383;&#21521;&#37327;&#65292;&#25509;&#19979;&#20358;&#20351;&#29992;&#30340; <code>Sys.time()</code> &#20989;&#25976;&#26159;&#19981;&#38656;&#35201;&#21443;&#25976;&#23601;&#26371;&#36664;&#20986;&#38651;&#33126;&#31995;&#32113;&#26085;&#26399;&#26178;&#38291;&#21521;&#37327;&#30340;&#20989;&#25976;&#12290;</p><pre><code>sys_time &lt;- Sys.time() # system time vector
print(sys_time)        # looks like a character
print(class(sys_time))
print(typeof(sys_time))</code></pre><p>R &#35486;&#35328;&#38928;&#35373;&#20197;&#35199;&#20803; 1970 &#24180; 1 &#26376; 1 &#26085;&#26684;&#26519;&#23612;&#27835;&#27161;&#28310;&#26178;&#38291;&#65288;Greenwich Mean Time&#65292;GMT&#65289;00 &#26178; 00 &#20998; 00 &#31186;&#20316;&#28858; 0&#65292;&#22312;&#36889;&#20491;&#26178;&#38291;&#40670;&#20197;&#24460;&#30340;&#27599;&#31186;&#37117; +1 &#20358;&#35352;&#37636;&#65292;&#36889;&#20491;&#26178;&#38291;&#40670;&#20197;&#21069;&#30340;&#27599;&#31186;&#37117; -1 &#20358;&#35352;&#37636;&#12290;&#25991;&#23383;&#21521;&#37327;&#33287;&#26085;&#26399;&#26178;&#38291;&#21521;&#37327;&#20841;&#32773;&#26368;&#22823;&#30340;&#20998;&#37326;&#65292;&#22312;&#26044;&#26085;&#26399;&#26178;&#38291;&#21521;&#37327;&#21487;&#20197;&#36914;&#34892;&#25976;&#20540;&#36939;&#31639;&#65292;&#32780;&#25991;&#23383;&#21521;&#37327;&#19981;&#34892;&#12290;</p><pre><code>print(sys_time - 1)
print(sys_time + 1)</code></pre><h2><strong>&#24314;&#31435;&#26410;&#23450;&#32681;&#20540;&#21521;&#37327;</strong></h2><p>R &#35486;&#35328;&#26377;&#35920;&#23500;&#30340;&#26410;&#23450;&#32681;&#20540;&#21521;&#37327;&#65292;&#29992;&#20358;&#34920;&#31034;&#19968;&#20123;&#29305;&#27530;&#24773;&#22659;&#25152;&#38656;&#35201;&#30340;&#34920;&#31034;&#65292;&#26377;&#36986;&#28431;&#20540;&#21521;&#37327; <code>NA</code>&#12289;&#31354;&#20540;&#21521;&#37327; <code>NULL</code>&#12289;&#38750;&#25976;&#20540;&#21521;&#37327; <code>NaN</code> &#20197;&#21450;&#28961;&#38480;&#22823;&#25976;&#20540;&#21521;&#37327; <code>Inf</code>&#12290;&#24314;&#31435;&#36889;&#20123;&#26410;&#23450;&#32681;&#20540;&#21521;&#37327;&#23601;&#20687;&#24314;&#31435;&#37007;&#36655;&#21521;&#37327;&#19968;&#33324;&#65292;&#30452;&#25509;&#36664;&#20837;&#20445;&#30041;&#23383;&#21363;&#21487;&#12290;</p><pre><code>print(NA)
print(NULL)
print(NaN)
print(Inf)
print(-Inf)</code></pre><p>&#22312;&#21021;&#27493;&#26296;&#35299;&#22914;&#20309;&#22312; R &#35486;&#35328;&#24314;&#31435;&#22522;&#26412;&#36039;&#26009;&#21934;&#20301;&#12300;&#21521;&#37327;&#12301;&#20043;&#24460;&#65292;&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;&#24314;&#31435;&#22522;&#26412;&#36039;&#26009;&#21934;&#20301;&#12300;&#21521;&#37327;&#12301;&#20358;&#21040;&#23614;&#32882;&#65292;&#24076;&#26395;&#24744;&#20063;&#21644;&#25105;&#19968;&#27171;&#26399;&#24453;&#19979;&#19968;&#31687;&#25991;&#31456;&#12290;</p><h2>&#24310;&#20280;&#38321;&#35712;</h2><ol><li><p><a href="https://r4ds.had.co.nz/vectors.html">https://r4ds.had.co.nz/vectors.html</a></p></li><li><p><a href="https://adv-r.hadley.nz/vectors-chap.html">https://adv-r.hadley.nz/vectors-chap.html</a></p></li></ol><p>&#23565;&#26044;&#36889;&#31687;&#25991;&#31456;&#26377;&#20160;&#40636;&#24819;&#27861;&#21602;&#65311;&#21916;&#27489;&#128571;&#12289;&#30041;&#35328;&#128587;&#8205;&#9794;&#65039;&#25110;&#32773;&#20998;&#20139;&#128588;</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://datainpoint.substack.com/p/week-twenty-five-creating-vectors/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://datainpoint.substack.com/p/week-twenty-five-creating-vectors/comments"><span>Leave a comment</span></a></p>
      <p>
          <a href="https://datainpoint.substack.com/p/week-twenty-five-creating-vectors">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[約維安計畫：對資料結構應用函數 ]]></title><description><![CDATA[&#31532;&#20108;&#21313;&#22235;&#36913;]]></description><link>https://datainpoint.substack.com/p/week-twenty-four-apply-functions-to-objects</link><guid isPermaLink="false">https://datainpoint.substack.com/p/week-twenty-four-apply-functions-to-objects</guid><dc:creator><![CDATA[Yao-Jen Kuo]]></dc:creator><pubDate>Thu, 17 Feb 2022 13:21:18 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!33wE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fafe2f57c-7450-4768-982e-948271341893_480x366.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!33wE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fafe2f57c-7450-4768-982e-948271341893_480x366.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!33wE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fafe2f57c-7450-4768-982e-948271341893_480x366.gif 424w, https://substackcdn.com/image/fetch/$s_!33wE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fafe2f57c-7450-4768-982e-948271341893_480x366.gif 848w, https://substackcdn.com/image/fetch/$s_!33wE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fafe2f57c-7450-4768-982e-948271341893_480x366.gif 1272w, https://substackcdn.com/image/fetch/$s_!33wE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fafe2f57c-7450-4768-982e-948271341893_480x366.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!33wE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fafe2f57c-7450-4768-982e-948271341893_480x366.gif" width="480" height="366" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/afe2f57c-7450-4768-982e-948271341893_480x366.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:366,&quot;width&quot;:480,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2128602,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!33wE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fafe2f57c-7450-4768-982e-948271341893_480x366.gif 424w, https://substackcdn.com/image/fetch/$s_!33wE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fafe2f57c-7450-4768-982e-948271341893_480x366.gif 848w, https://substackcdn.com/image/fetch/$s_!33wE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fafe2f57c-7450-4768-982e-948271341893_480x366.gif 1272w, https://substackcdn.com/image/fetch/$s_!33wE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fafe2f57c-7450-4768-982e-948271341893_480x366.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#20358;&#28304;&#65306;giphy.com</figcaption></figure></div><h2>&#35299;&#26512;&#21704;&#22217;&#19990;&#30028;</h2><p>&#22312;<a href="https://datainpoint.substack.com/p/week-twenty-three-getting-started-with-r">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;R &#35486;&#35328;&#36215;&#27493;&#36208;</a>&#25105;&#20497;&#36879;&#36942; <code>print("Hello, World!") &#20358;</code>&#30906;&#35469; R &#35486;&#35328;&#30340;&#38283;&#30332;&#29872;&#22659;&#21450;&#22519;&#34892;&#29872;&#22659;&#26159;&#21542;&#24050;&#32147;&#23433;&#35037;&#22949;&#30070;&#65292;&#22312;&#36889;&#19968;&#27573;&#21704;&#22217;&#19990;&#30028;&#30340;&#31243;&#24335;&#30908;&#20013;&#65292;&#20854;&#23526;&#23601;&#33021;&#39636;&#26371;&#25105;&#20497;&#22312;&#25991;&#31456;&#19968;&#38283;&#22987;&#24341;&#29992; Greg Martin &#23565;&#26044; R &#35486;&#35328;&#26680;&#24515;&#31934;&#31070;&#30340;&#35438;&#37323;&#65306;&#23565;&#36039;&#26009;&#32080;&#27083;&#25033;&#29992;&#20989;&#25976;&#12290;</p><blockquote><p>The way R works is pretty straightforward, you apply functions to objects.</p><p><a href="https://www.youtube.com/user/drgregmartin">Greg Martin</a></p></blockquote><p><code>print</code> &#26159;&#20989;&#25976;&#30340;&#21517;&#31281;&#65292;<code>print()</code> &#21063;&#34920;&#31034;&#35201;&#25033;&#29992;&#35442;&#20989;&#25976;&#30340;&#21151;&#33021;&#65292;&#32780; <code>&#8220;Hello, World!&#8220;</code> &#21063;&#26159;&#19968;&#20491;&#34987;&#31281;&#21628;&#28858;&#25991;&#23383;&#65288;Character&#65289;&#30340;&#21521;&#37327;&#36039;&#26009;&#32080;&#27083;&#65307;&#25563;&#35328;&#20043;&#65292;&#21704;&#22217;&#19990;&#30028;&#21487;&#20197;&#34920;&#36948;&#28858;&#65306;&#23565; <code>&#8220;Hello, World!&#8220;</code> &#36889;&#20491;&#25991;&#23383;&#21521;&#37327;&#25033;&#29992;&#20102; <code>print()</code> &#20989;&#25976;&#12290;</p><pre><code>print("Hello, World!")
## [1] "Hello, World!"</code></pre><h2>&#20160;&#40636;&#26159;&#20989;&#25976;</h2><p>&#20989;&#25976;&#26159;&#27083;&#25104;&#25152;&#26377;&#31243;&#24335;&#35486;&#35328;&#30340;&#22522;&#26412;&#35201;&#32032;&#65292;&#19968;&#20491;&#20989;&#25976;&#26159;&#19968;&#27573;&#12300;&#34987;&#21629;&#21517;&#12301;&#30340;&#31243;&#24335;&#30908;&#65292;&#36889;&#27573;&#31243;&#24335;&#30908;&#21487;&#20197;&#29992;&#26044;&#22519;&#34892;&#26576;&#20491;&#29305;&#23450;&#20219;&#21209;&#65292;&#21487;&#33021;&#26159;&#25976;&#20540;&#30340;&#36939;&#31639;&#25110;&#32773;&#25991;&#23383;&#30340;&#34389;&#29702;&#65292;&#30070;&#20351;&#29992;&#32773;&#24819;&#35201;&#25033;&#29992;&#65288;&#20351;&#29992;&#12289;&#21628;&#21483;&#65289;&#26576;&#19968;&#20491;&#20989;&#25976;&#20043;&#21069;&#65292;&#24517;&#38920;&#20808;&#30906;&#23450;&#22312;&#27442;&#29986;&#29983;&#20316;&#29992;&#30340;&#31684;&#30087;&#20013;&#35442;&#20989;&#25976;&#24050;&#32147;&#34987;&#23450;&#32681;&#25110;&#32773;&#34987;&#36617;&#20837;&#12290;&#31777;&#32780;&#35328;&#20043;&#65292;&#22312;&#21704;&#22217;&#19990;&#30028;&#30340;&#31243;&#24335;&#30908;&#20013;&#65292;&#20043;&#25152;&#20197;&#33021;&#22816;&#23565;&#23383;&#20018; <code>&#8220;Hello, World!&#8220;</code> &#25033;&#29992; <code>print()</code> &#20989;&#25976;&#65292;&#26159;&#22240;&#28858; <code>print()</code> &#20989;&#25976;&#23660;&#26044; R &#35486;&#35328;&#30340;&#20839;&#24314;&#20989;&#25976;&#65292;&#22312; R &#35486;&#35328;&#21855;&#21205;&#30340;&#30070;&#19979;&#23601;&#26371;&#34987;&#36617;&#20837;&#20379;&#25105;&#20497;&#20351;&#29992;&#12290;</p><h2>&#20989;&#25976;&#30340;&#20358;&#28304;</h2><p>R &#35486;&#35328;&#20351;&#29992;&#32773;&#38500;&#20102;&#33021;&#22816;&#25033;&#29992;&#20839;&#24314;&#20989;&#25976;&#20197;&#22806;&#65292;&#36996;&#21487;&#20197;&#24478;&#20854;&#20182;&#20841;&#20491;&#31649;&#36947;&#21462;&#24471;&#25152;&#38656;&#35201;&#30340;&#20989;&#25976;&#65306;</p><ol><li><p>&#22871;&#20214;&#65288;Packages&#65289;&#12290;</p></li><li><p>&#33258;&#34892;&#23450;&#32681;&#12290;</p></li></ol><p>&#20677;&#26377;&#20839;&#24314;&#20989;&#25976;&#21487;&#20197;&#20379;&#25105;&#20497;&#30452;&#25509;&#20351;&#29992;&#65292;&#21478;&#22806;&#20841;&#20491;&#31649;&#36947;&#30340;&#20989;&#25976;&#37117;&#24517;&#38920;&#22312;&#20351;&#29992;&#20043;&#21069;&#30906;&#23450;&#22909;&#22312;&#27442;&#29986;&#29983;&#20316;&#29992;&#30340;&#31684;&#30087;&#20013;&#24050;&#32147;&#34987;&#36617;&#20837;&#25110;&#32773;&#23450;&#32681;&#12290;&#20351;&#29992;&#22871;&#20214;&#20013;&#30340;&#20989;&#25976;&#20043;&#21069;&#65292;&#25105;&#20497;&#24517;&#38920;&#30906;&#35469;&#22871;&#20214;&#26159;&#21542;&#24050;&#32147;&#23433;&#35037;&#12289;&#36617;&#20837;&#65292;&#20351;&#29992;&#33258;&#34892;&#23450;&#32681;&#30340;&#20989;&#25976;&#20043;&#21069;&#65292;&#21063;&#26159;&#24517;&#38920;&#30906;&#35469;&#35442;&#20989;&#25976;&#26159;&#21542;&#24050;&#32147;&#23436;&#25104;&#23450;&#32681;&#12290;&#36617;&#20837;&#22871;&#20214;&#30340;&#20989;&#25976;&#26159; <code>library()</code>&#12290;</p><pre><code>library("package_name")

function_name()</code></pre><p>&#25105;&#20497;&#30701;&#26399;&#36996;&#27794;&#26377;&#35201;&#20351;&#29992;&#22871;&#20214;&#20013;&#30340;&#20989;&#25976;&#65292;&#19981;&#36942;&#20498;&#26159;&#39340;&#19978;&#26371;&#26377;&#33258;&#34892;&#23450;&#32681;&#20989;&#25976;&#30340;&#38656;&#27714;&#65292;&#33258;&#34892;&#23450;&#32681;&#20989;&#25976;&#38656;&#35201;&#32771;&#24942;&#20116;&#20491;&#32068;&#25104;&#35201;&#20214;&#65306;</p><ol><li><p>&#20989;&#25976;&#21517;&#31281;&#12290;</p></li><li><p>&#36664;&#20837;&#12290;</p></li><li><p>&#21443;&#25976;&#12290;</p></li><li><p>&#20989;&#25976;&#20027;&#39636;&#12290;</p></li><li><p>&#36664;&#20986;&#12290;</p></li></ol><p>&#30475;&#20284;&#25277;&#35937;&#65292;&#19981;&#36942;&#24819;&#24819;&#24179;&#26085;&#36092;&#36023;&#29645;&#29664;&#39854;&#22902;&#33590;&#30340;&#27969;&#31243;&#65292;&#23601;&#20687;&#26159;&#20989;&#25976;&#30340;&#36939;&#20316;&#19968;&#33324;&#65306;</p><ol><li><p>&#20989;&#25976;&#21517;&#31281;&#65306;&#36092;&#36023;&#29645;&#29664;&#39854;&#22902;&#33590;&#12290;</p></li><li><p>&#36664;&#20837;&#65306;&#20013;&#26479; 35 &#20803;&#65307;&#22823;&#26479; 50 &#20803;&#12290;</p></li><li><p>&#21443;&#25976;&#65306;&#29980;&#24230;&#65288;&#28961;&#31958;&#12289;&#24494;&#31958;&#12289;&#21322;&#31958;&#12289;&#23569;&#31958;&#12289;&#20840;&#31958;&#65289;&#33287;&#20912;&#22602;&#65288;&#21435;&#20912;&#12289;&#23569;&#20912;&#12289;&#20840;&#20912;&#65289;&#12290;</p></li><li><p>&#20989;&#25976;&#20027;&#39636;&#65306;&#40670;&#39184;&#12289;&#36028;&#27161;&#31844;&#12289;&#21152;&#29645;&#29664;&#12289;&#21152;&#20912;&#22602;&#12289;&#20498;&#33590;&#12289;&#21152;&#39854;&#22902;&#19968;&#30452;&#21040;&#23553;&#21475;&#12290;</p></li><li><p>&#36664;&#20986;&#65306;&#29645;&#29664;&#39854;&#22902;&#33590;&#12290;</p></li></ol><pre><code>function_name &lt;- function(INPUTS, PARAMETERS){
    # body of the function
    # ...
    # ...sequence of statements
    return(OUTPUTS)
}</code></pre><p><code>#</code>&nbsp;&#26159;&#29992;&#20358;&#27161;&#35352;&#35387;&#35299;&#30340;&#31526;&#34399;&#65292;&#26377; <code>#</code> &#27161;&#35352;&#30340;&#35442;&#34892;&#25944;&#36848;&#23559;&#19981;&#26371;&#34987; R &#35486;&#35328;&#22519;&#34892;&#65292;&#36889;&#35731;&#23531;&#31243;&#24335;&#30340;&#20154;&#33021;&#22816;&#29992;&#21475;&#35486;&#20358;&#25551;&#36848;&#36889;&#27573;&#31243;&#24335;&#30340;&#30446;&#30340;&#26159;&#20160;&#40636;&#65292;&#22914;&#26524;&#23559;&#21704;&#22217;&#19990;&#30028;&#25913;&#23531;&#28858;&#20989;&#25976;&#24418;&#24335;&#65292;&#27599;&#27425;&#21482;&#38656;&#35201;&#36664;&#20837;&#20989;&#25976;&#21517;&#31281;&#20006;&#21152;&#19978;&#23567;&#25324;&#34399; <code>hello_world()</code>&#65292;&#23601;&#21487;&#20197;&#29554;&#24471; <code>&#8220;Hello, World!&#8220;</code> &#36889;&#20491;&#25991;&#23383;&#21521;&#37327;&#28858;&#36664;&#20986;&#12290;</p><pre><code>hello_world &lt;- function(){
    return("Hello, World!")
}
hello_world()
## [1] "Hello, World!"</code></pre><h2>&#24314;&#31435;&#29289;&#20214;</h2><p>&#38500;&#20102;&#30452;&#25509;&#23565; <code>&#8220;Hello, World!&#8220;</code> &#25991;&#23383;&#21521;&#37327;&#25033;&#29992; <code>print()</code> &#20989;&#25976;&#65292;&#26356;&#24120;&#35211;&#30340;&#20316;&#27861;&#26159;&#23559;&#36039;&#26009;&#36070;&#20540;&#32102;&#29289;&#20214;&#65288;Objects&#65289;&#65292;&#28982;&#24460;&#20877;&#23565;&#29289;&#20214;&#25033;&#29992;&#20989;&#25976;&#65292;&#23436;&#25972;&#30340;&#35498;&#27861;&#28858; <code>a_character</code> &#29289;&#20214;&#26159;&#25991;&#23383;&#21521;&#37327;&#36889;&#20491;&#36039;&#26009;&#32080;&#27083;&#30340;&#23526;&#20363;&#65288;Instance&#65289;&#12290;</p><pre><code>a_character &lt;- "Hello, World!"
a_character
## [1] "Hello, World!"</code></pre><p>&#22312;&#28858;&#29289;&#20214;&#21462;&#21517;&#31281;&#30340;&#26178;&#20505;&#65292;&#25033;&#35442;&#35201;&#35641;&#35352;&#22235;&#20491;&#21407;&#21063;&#65306;</p><ol><li><p>&#21629;&#21517;&#30340;&#26178;&#20505;&#20351;&#29992;&#26377;&#24847;&#32681;&#30340;&#20840;&#23567;&#23531;&#33521;&#25991;&#65292;&#25505;&#29992;&#34503;&#24418;&#21629;&#21517;&#27861;&#65288;Snake-case&#65289;&#65292;&#19981;&#21516;&#21934;&#23383;&#20043;&#38291;&#20197;&#24213;&#32218; <code>_</code> &#30456;&#38548;&#65307;&#25110;&#32773;&#25505;&#29992;&#39389;&#23792;&#21629;&#21517;&#27861;&#65288;Camel-case&#65289;&#65292;&#19981;&#21516;&#21934;&#23383;&#20043;&#38291;&#20197;&#22823;&#23531;&#21312;&#38548;&#12290;&#20363;&#22914; <code>a_character</code> &#25110;&#32773; <code>aCharacter</code></p></li><li><p>&#20351;&#29992; <code>&lt;-</code> &#32780;&#38750; <code>=</code> &#20316;&#28858;&#36070;&#20540;&#36939;&#31639;&#31526;&#12290;</p></li><li><p>&#19981;&#21487;&#20197;&#20351;&#29992;<strong>&#20445;&#30041;&#23383;</strong>&#20570;&#28858;&#29289;&#20214;&#30340;&#21629;&#21517;&#65292;&#36889;&#27171;&#20570;&#23559;&#26371;&#29986;&#29983;&#30452;&#35695;&#37679;&#35492;&#12290;</p></li><li><p>&#19981;&#35201;&#20351;&#29992;<strong>&#20839;&#24314;&#20989;&#25976;</strong>&#20570;&#28858;&#29289;&#20214;&#30340;&#21629;&#21517;&#65292;&#36889;&#27171;&#20570;&#23559;&#26371;&#35206;&#33995;&#20839;&#24314;&#20989;&#25976;&#30340;&#21151;&#33021;&#12290;</p></li></ol><p>&#20854;&#20013; R &#35486;&#35328;&#30340;&#20445;&#30041;&#23383;&#21487;&#20197;&#36879;&#36942; help(reserved) &#20358;&#26597;&#35426;&#12290;</p><pre><code>help(reserved)
## if else repeat while function for in next break
## TRUE FALSE NULL Inf NaN NA 
## NA_integer_ NA_real_ NA_complex_ NA_character_</code></pre><h2>&#20160;&#40636;&#26159;&#36039;&#26009;&#32080;&#27083;</h2><p>&#22312;&#38651;&#33126;&#31185;&#23416;&#20013;&#36039;&#26009;&#32080;&#27083;&#26159;&#29992;&#20358;&#20786;&#23384;&#12289;&#32068;&#32340;&#20197;&#21450;&#23384;&#21462;&#25976;&#25818;&#30340;&#27231;&#21046;&#65292;&#36039;&#26009;&#31185;&#23416;&#23478;&#26085;&#24120;&#24037;&#20316;&#20013;&#22823;&#24133;&#20208;&#36084;&#36039;&#26009;&#32080;&#27083;&#20316;&#28858;&#36664;&#20837;&#12289;&#28165;&#29702;&#12289;&#36681;&#25563;&#12289;&#20998;&#26512;&#33287;&#36664;&#20986;&#25976;&#25818;&#30340;&#24179;&#21488;&#12290;R &#35486;&#35328;&#33287;&#20854;&#20182;&#31243;&#24335;&#35486;&#35328;&#65288;&#20363;&#22914; Python&#65289;&#26368;&#22823;&#30340;&#24046;&#30064;&#22312;&#26044;&#22905;&#30465;&#30053;&#20102;&#12300;&#36039;&#26009;&#39006;&#21029;&#12301;&#36889;&#20491;&#23652;&#32026;&#65292;&#30452;&#25509;&#20197;&#12300;&#36039;&#26009;&#32080;&#27083;&#12301;&#20316;&#28858;&#26368;&#22522;&#26412;&#30340;&#21934;&#20301;&#65292;&#36889;&#40670;&#26159;&#19968;&#20491;&#24456;&#22823;&#30340;&#19981;&#21516;&#12290;</p><p>R &#35486;&#35328;&#26368;&#22522;&#26412;&#30340;&#36039;&#26009;&#32080;&#27083;&#26159;&#21521;&#37327;&#65288;<code>vector</code>&#65289;&#65292;&#30001;&#21521;&#37327;&#21487;&#20197;&#20877;&#32068;&#32340;&#12289;&#36681;&#25563;&#28858;&#20854;&#20182;&#30340;&#36039;&#26009;&#32080;&#27083;&#65292;&#24120;&#29992;&#30340;&#20845;&#31278;&#22522;&#26412;&#36039;&#26009;&#32080;&#27083;&#26377;&#65306;</p><ol><li><p>&#21521;&#37327;&#65288;<code>vector</code>&#65289;&#12290;</p></li><li><p>&#30697;&#38499;&#65288;<code>matrix</code>&#65289;&#20108;&#32173;&#21521;&#37327;&#12290;</p></li><li><p>&#38499;&#21015;&#65288;<code>array</code>&#65289;n &#32173;&#21521;&#37327;&#12290;</p></li><li><p>&#22240;&#32032;&#21521;&#37327;&#65288;<code>factor</code>&#65289;&#20855;&#26377;&#25972;&#25976;&#32232;&#30908;&#30340;&#25991;&#23383;&#21521;&#37327;&#12290;</p></li><li><p>&#28165;&#21934;&#65288;<code>list</code>&#65289;&#19968;&#32173;&#30064;&#36074;&#21521;&#37327;&#12290;</p></li><li><p>&#36039;&#26009;&#26694;&#65288;<code>data.frame</code>&#65289;&#20108;&#32173;&#30064;&#36074;&#21521;&#37327;&#12290;</p></li></ol><p>&#32780;&#21521;&#37327;&#20316;&#28858;&#26368;&#22522;&#26412;&#30340;&#21934;&#20301;&#65292;&#36996;&#21487;&#20197;&#20877;&#32048;&#20998;&#28858;&#19971;&#31278;&#19981;&#21516;&#39006;&#22411;&#65306;</p><ol><li><p>&#25976;&#20540;&#65288;<code>numeric</code>&#65289;&#12290;</p></li><li><p>&#25972;&#25976;&#65288;<code>integer</code>&#65289;&#12290;</p></li><li><p>&#25991;&#23383;&#65288;<code>character</code>&#65289;&#12290;</p></li><li><p>&#37007;&#36655;&#65288;<code>logical</code>&#65289;&#12290;</p></li><li><p>&#26085;&#26399;&#65288;<code>date</code>&#65289;&#12290;</p></li><li><p>&#26085;&#26399;&#26178;&#38291;&#65288;<code>POSIXct</code>&#65289;&#12290;</p></li><li><p>&#26410;&#23450;&#32681;&#20540;&#65288;<code>NA/NULL/NaN/-Inf/Inf</code>&#65289;&#12290;</p></li></ol><p>&#30001;&#26044;&#24120;&#35211;&#23565;&#36039;&#26009;&#32080;&#27083;&#25033;&#29992;&#20989;&#25976;&#30340;&#26178;&#20505;&#65292;&#37117;&#26159;&#23565;&#24314;&#31435;&#23436;&#25104;&#30340;&#29289;&#20214;&#25033;&#29992;&#65292;&#32780;&#38750;&#30452;&#25509;&#23565;&#36039;&#26009;&#32080;&#27083;&#26412;&#36523;&#25033;&#29992;&#65292;&#36889;&#26159;&#22240;&#28858;&#31243;&#24335;&#35373;&#35336;&#36890;&#24120;&#22312;&#24460;&#32396;&#26371;&#26377;&#36039;&#26009;&#35352;&#37636;&#33287;&#36939;&#31639;&#34389;&#29702;&#30340;&#38656;&#27714;&#65292;&#20006;&#19981;&#20677;&#27490;&#33287;&#23559;&#20854;&#21360;&#20986;&#20358;&#32780;&#24050;&#12290;&#25152;&#20197;&#25105;&#20497;&#38656;&#35201;&#19968;&#20491;&#33021;&#22816;&#23559;&#23436;&#25104;&#23459;&#21578;&#30340;&#29289;&#20214;&#25152;&#20786;&#23384;&#20043;&#36039;&#26009;&#32080;&#27083;&#21578;&#30693;&#20351;&#29992;&#32773;&#30340;&#20839;&#24314;&#20989;&#25976;&#65292;&#36889;&#20491;&#20839;&#24314;&#20989;&#25976;&#26159; <code>class()</code> &#25110;&#32773;&nbsp;<code>typeof()&#65292;&#20316;&#29992;&#26159;&#23559;&#34987;&#25033;&#29992;&#29289;&#20214;&#30340;&#36039;&#26009;&#32080;&#27083;&#22238;&#20659;&#12290;</code></p><pre><code>a_character &lt;- "Hello, World!"
class(a_character)
## [1] "character"
typeof(a_character)
## [1] "character"</code></pre><h2>&#23565;&#36039;&#26009;&#32080;&#27083;&#25033;&#29992;&#20989;&#25976;&#30340;&#20841;&#31278;&#35486;&#27861;</h2><p>&#22312; R &#35486;&#35328;&#20013;&#23565;&#36039;&#26009;&#32080;&#27083;&#25033;&#29992;&#20989;&#25976;&#21487;&#20197;&#20351;&#29992;&#20841;&#31278;&#35486;&#27861;&#65306;</p><ol><li><p><code>function_name(object_name)</code></p></li><li><p><code>object_name PIPE OPERATOR function_name()</code></p></li></ol><p>&#31532;&#19968;&#31278;&#26159;&#26368;&#28858;&#24120;&#35211;&#12289;&#20063;&#26356;&#28858;&#22823;&#30526;&#25509;&#21463;&#30340;&#35486;&#27861;&#65292;&#20989;&#25976;&#21517;&#31281;&#30340;&#23567;&#25324;&#34399;&#20013;&#36664;&#20837;&#29289;&#20214;&#21517;&#31281;&#12290;</p><pre><code>a_character &lt;- "Hello, World!"
print(a_character)
## [1] "Hello, World!"</code></pre><p>&#31532;&#20108;&#31278;&#21063;&#26159;&#27604;&#36611;&#23569;&#35211;&#30340;&#35486;&#27861;&#65292;&#29289;&#20214;&#21517;&#31281;&#24460;&#21152;&#20837;&#19968;&#20491; <code>PIPE OPERATOR</code> &#36899;&#32080;&#20989;&#25976;&#21517;&#31281;&#30340;&#23567;&#25324;&#34399;&#12290;</p><pre><code>a_character &lt;- "Hello, World!"
a_character |&gt; print()
## [1] "Hello, World!"</code></pre><p>&#20854;&#20013;&#30340; <code>|&gt;</code> &#23601;&#26159;&#25152;&#35586;&#30340; <code>PIPE OPERATOR</code>&#65292;&#22312; R4.1 &#20197;&#24460;&#30340;&#29256;&#26412;&#26159;&#20839;&#24314;&#30340;&#36939;&#31639;&#31526;&#34399;&#65292;&#22914;&#26524;&#26159;&#22312; R4.1 &#20197;&#21069;&#30340;&#29256;&#26412;&#65292;&#23601;&#35201;&#20351;&#29992; magrittr &#22871;&#20214;&#32102;&#20104;&#30340; %&gt;% &#20316;&#28858; <code>PIPE OPERATOR</code></p><pre><code># install.packages("magrittr")
library("magrittr")

a_character &lt;- "Hello, World!"
a_character %&gt;% print()
## [1] "Hello, World!"</code></pre><p>&#22312;&#21021;&#27493;&#35469;&#35672; R &#35486;&#35328;&#30340;&#20989;&#25976;&#33287;&#36039;&#26009;&#32080;&#27083;&#20043;&#24460;&#65292;&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;&#23565;&#36039;&#26009;&#32080;&#27083;&#25033;&#29992;&#20989;&#25976;&#20358;&#21040;&#23614;&#32882;&#65292;&#24076;&#26395;&#24744;&#20063;&#21644;&#25105;&#19968;&#27171;&#26399;&#24453;&#19979;&#19968;&#31687;&#25991;&#31456;&#12290;</p><h2>&#24310;&#20280;&#38321;&#35712;</h2><ol><li><p><a href="https://adv-r.hadley.nz/functions.html">https://adv-r.hadley.nz/functions.html</a></p></li><li><p><a href="https://adv-r.hadley.nz/vectors-chap.html">https://adv-r.hadley.nz/vectors-chap.html</a></p></li><li><p><a href="https://r4ds.had.co.nz/pipes.html">https://r4ds.had.co.nz/pipes.html</a></p></li></ol><p>&#23565;&#26044;&#36889;&#31687;&#25991;&#31456;&#26377;&#20160;&#40636;&#24819;&#27861;&#21602;&#65311;&#21916;&#27489;&#128571;&#12289;&#30041;&#35328;&#128587;&#8205;&#9794;&#65039;&#25110;&#32773;&#20998;&#20139;&#128588;</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://datainpoint.substack.com/p/week-twenty-four-apply-functions-to-objects/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://datainpoint.substack.com/p/week-twenty-four-apply-functions-to-objects/comments"><span>Leave a comment</span></a></p><h2>&#35336;&#30059;&#23416;&#21729;&#23560;&#21312;</h2><p>&#20184;&#36027;&#35330;&#38321;&#38651;&#23376;&#22577;&#30340;&#26371;&#21729;&#21487;&#20197;&#40670;&#36984; <a href="https://lab.datainpoint.com/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fdatainpoint%2Fweek-twenty-four-apply-functions-to-data-structures&amp;urlpath=tree%2Fweek-twenty-four-apply-functions-to-data-structures%2F">nbgitpuller &#36899;&#32080;</a>&#23559;&#26412;&#31687;&#25991;&#31456;&#23436;&#25972;&#30340; Jupyter Notebook &#35079;&#35069;&#21040;&#33258;&#24049;&#30340; Jupyter Server&#65306;</p><p><a href="https://lab.datainpoint.com/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fdatainpoint%2Fweek-twenty-four-apply-functions-to-data-structures&amp;urlpath=tree%2Fweek-twenty-four-apply-functions-to-data-structures%2F">nbgitpuller &#36899;&#32080;</a></p><p>&#20282;&#26381;&#22120;&#36984;&#38917;&#36984;&#25799;&#38928;&#35373;&#30340;&#12300;Data science environment&#65306;&#23416;&#32722; Python&#12289;R &#33287; Julia &#30340;&#36039;&#26009;&#31185;&#23416;&#29872;&#22659;&#12301;&#23601;&#21487;&#20197;&#38918;&#21033;&#36939;&#20316;&#25991;&#31456;&#20013;&#30340;&#31684;&#20363;&#31243;&#24335;&#12290;</p><p>&#24536;&#35352;&#20102;&#20160;&#40636;&#26159; Jupyter &#26143;&#29699;&#21966;&#65311;&#35079;&#32722;&#19968;&#19979;<a href="https://datainpoint.substack.com/p/week-zero-welcome">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;&#27489;&#36814;&#20809;&#33256; Jupyter &#26143;&#29699;</a>&#21543;&#65281;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HMwv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HMwv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 424w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 848w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1272w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!HMwv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png" width="1456" height="964" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:964,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:137396,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!HMwv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 424w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 848w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1272w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#36984;&#25799;&#12300;Data science environment&#65306;&#23416;&#32722; Python&#12289;R &#33287; Julia &#30340;&#36039;&#26009;&#31185;&#23416;&#29872;&#22659;&#12301;</figcaption></figure></div>]]></content:encoded></item><item><title><![CDATA[約維安計畫：R 語言起步走]]></title><description><![CDATA[&#31532;&#20108;&#21313;&#19977;&#36913;]]></description><link>https://datainpoint.substack.com/p/week-twenty-three-getting-started-with-r</link><guid isPermaLink="false">https://datainpoint.substack.com/p/week-twenty-three-getting-started-with-r</guid><dc:creator><![CDATA[Yao-Jen Kuo]]></dc:creator><pubDate>Mon, 31 Jan 2022 14:23:27 GMT</pubDate><enclosure url="https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/e36e376c-37fd-4a9c-b184-79ee91555a0d_480x251.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!IbYL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F346060d2-9a59-4ff0-9d1a-728a79787baf_480x251.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!IbYL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F346060d2-9a59-4ff0-9d1a-728a79787baf_480x251.gif 424w, https://substackcdn.com/image/fetch/$s_!IbYL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F346060d2-9a59-4ff0-9d1a-728a79787baf_480x251.gif 848w, https://substackcdn.com/image/fetch/$s_!IbYL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F346060d2-9a59-4ff0-9d1a-728a79787baf_480x251.gif 1272w, https://substackcdn.com/image/fetch/$s_!IbYL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F346060d2-9a59-4ff0-9d1a-728a79787baf_480x251.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!IbYL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F346060d2-9a59-4ff0-9d1a-728a79787baf_480x251.gif" width="480" height="251" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/346060d2-9a59-4ff0-9d1a-728a79787baf_480x251.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:251,&quot;width&quot;:480,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:149118,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!IbYL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F346060d2-9a59-4ff0-9d1a-728a79787baf_480x251.gif 424w, https://substackcdn.com/image/fetch/$s_!IbYL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F346060d2-9a59-4ff0-9d1a-728a79787baf_480x251.gif 848w, https://substackcdn.com/image/fetch/$s_!IbYL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F346060d2-9a59-4ff0-9d1a-728a79787baf_480x251.gif 1272w, https://substackcdn.com/image/fetch/$s_!IbYL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F346060d2-9a59-4ff0-9d1a-728a79787baf_480x251.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#20358;&#28304;&#65306;giphy.com</figcaption></figure></div><blockquote><p>The way R works is pretty straightforward, you apply functions to objects.</p><p><a href="https://www.youtube.com/user/drgregmartin">Greg Martin</a></p></blockquote><p>R &#35486;&#35328;&#30001;&#32016;&#35199;&#34349;&#22887;&#20811;&#34349;&#22823;&#23416;&#30340; Ross Ihaka &#21644; Robert Gentleman &#25152;&#35373;&#35336;&#12289;R &#26680;&#24515;&#22296;&#38538;&#32173;&#35703;&#65292;&#26159;&#19968;&#20491;&#38283;&#28304;&#30340;&#32113;&#35336;&#31243;&#24335;&#35486;&#35328;&#65292;&#24120;&#29992;&#26044;&#38283;&#30332;&#32113;&#35336;&#21644;&#36039;&#26009;&#20998;&#26512;&#36575;&#39636;&#31995;&#32113;&#65292;&#36817;&#24180;&#22312; Hadley Wickham &#33287; RStudio &#22296;&#38538;&#25152;&#24314;&#27083;&#30340;&#25033;&#29992;&#22871;&#20214; <a href="https://www.tidyverse.org/">Tidyverse</a> &#29983;&#24907;&#31995;&#20197;&#21450;&#22823;&#25976;&#25818;&#12289;&#36039;&#26009;&#31185;&#23416;&#33287;&#20154;&#24037;&#26234;&#24935;&#30340;&#29105;&#28526;&#21152;&#25345;&#65292;&#24291;&#21463;&#32113;&#35336;&#23416;&#23478;&#21644;&#36039;&#26009;&#31185;&#23416;&#23478;&#30340;&#29105;&#24859;&#12290;</p><h2>R &#35486;&#35328;&#30340;&#21463;&#27489;&#36814;&#31243;&#24230;</h2><p>&#25130;&#33267; 2022 &#24180; 1 &#26376;&#65292;R &#35486;&#35328;&#22312; <a href="https://www.tiobe.com/tiobe-index/">TIOBE Index</a> &#25490;&#21517;&#31532; 12&#12289;&#22312; <a href="https://spectrum.ieee.org/top-programming-languages/">IEEE Top Programming Languages 2021</a> &#35519;&#26597;&#25490;&#21517;&#31532; 7&#12290;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!fL7T!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F990e962d-f796-40be-91da-a365aae42b37_2322x1982.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fL7T!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F990e962d-f796-40be-91da-a365aae42b37_2322x1982.png 424w, https://substackcdn.com/image/fetch/$s_!fL7T!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F990e962d-f796-40be-91da-a365aae42b37_2322x1982.png 848w, https://substackcdn.com/image/fetch/$s_!fL7T!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F990e962d-f796-40be-91da-a365aae42b37_2322x1982.png 1272w, https://substackcdn.com/image/fetch/$s_!fL7T!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F990e962d-f796-40be-91da-a365aae42b37_2322x1982.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!fL7T!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F990e962d-f796-40be-91da-a365aae42b37_2322x1982.png" width="1456" height="1243" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/990e962d-f796-40be-91da-a365aae42b37_2322x1982.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1243,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:421102,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!fL7T!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F990e962d-f796-40be-91da-a365aae42b37_2322x1982.png 424w, https://substackcdn.com/image/fetch/$s_!fL7T!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F990e962d-f796-40be-91da-a365aae42b37_2322x1982.png 848w, https://substackcdn.com/image/fetch/$s_!fL7T!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F990e962d-f796-40be-91da-a365aae42b37_2322x1982.png 1272w, https://substackcdn.com/image/fetch/$s_!fL7T!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F990e962d-f796-40be-91da-a365aae42b37_2322x1982.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#22312; TIOBE Index &#25490;&#21517;&#31532; 12 &#20301;</figcaption></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!vRHB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F6a1e40d3-2993-4e5c-9b33-1511e1fc6b77_1760x2150.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!vRHB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F6a1e40d3-2993-4e5c-9b33-1511e1fc6b77_1760x2150.png 424w, https://substackcdn.com/image/fetch/$s_!vRHB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F6a1e40d3-2993-4e5c-9b33-1511e1fc6b77_1760x2150.png 848w, https://substackcdn.com/image/fetch/$s_!vRHB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F6a1e40d3-2993-4e5c-9b33-1511e1fc6b77_1760x2150.png 1272w, https://substackcdn.com/image/fetch/$s_!vRHB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F6a1e40d3-2993-4e5c-9b33-1511e1fc6b77_1760x2150.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!vRHB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F6a1e40d3-2993-4e5c-9b33-1511e1fc6b77_1760x2150.png" width="1456" height="1779" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/6a1e40d3-2993-4e5c-9b33-1511e1fc6b77_1760x2150.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1779,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:301267,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!vRHB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F6a1e40d3-2993-4e5c-9b33-1511e1fc6b77_1760x2150.png 424w, https://substackcdn.com/image/fetch/$s_!vRHB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F6a1e40d3-2993-4e5c-9b33-1511e1fc6b77_1760x2150.png 848w, https://substackcdn.com/image/fetch/$s_!vRHB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F6a1e40d3-2993-4e5c-9b33-1511e1fc6b77_1760x2150.png 1272w, https://substackcdn.com/image/fetch/$s_!vRHB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F6a1e40d3-2993-4e5c-9b33-1511e1fc6b77_1760x2150.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#22312; 2020 IEEE Top Programming Languages &#35519;&#26597;&#25490;&#21517;&#31532; 7 &#20301;</figcaption></figure></div><p>&#23565;&#27604;&#33287; R &#35486;&#35328;&#23450;&#20301;&#30456;&#21516;&#12289;&#20197;&#36039;&#26009;&#20998;&#26512;&#28858;&#20027;&#25033;&#29992;&#30340;&#31243;&#24335;&#35486;&#35328;&#65306;Matlab &#22312; TIOBE Index &#25490;&#21517;&#31532; 16 &#12289;&#22312; IEEE Top Programming Languages &#25490;&#21517;&#31532; 12&#65307;Julia &#22312; TIOBE Index &#25490;&#21517;&#31532; 28&#12289;&#22312; IEEE Top Programming Languages &#25490;&#21517;&#31532; 20&#65307;SAS &#22312; TIOBE Index &#25490;&#21517;&#31532; 22&#12289;&#22312; IEEE Top Programming Languages &#25490;&#21517;&#31532; 30&#12290;</p><p>&#24478;&#36889;&#20123;&#23560;&#27880;&#36039;&#26009;&#20998;&#26512;&#28858;&#20027;&#25033;&#29992;&#30340;&#31243;&#24335;&#35486;&#35328;&#25490;&#21517;&#20358;&#30475;&#65292;&#26410;&#20358; Analytic Programmer&#65288;&#25797;&#38263;&#36039;&#26009;&#20998;&#26512;&#30340;&#31243;&#24335;&#35373;&#35336;&#24107;&#65289;&#25110;&#32773; Programming Analyst&#65288;&#25797;&#38263;&#31243;&#24335;&#35373;&#35336;&#30340;&#36039;&#26009;&#20998;&#26512;&#24107;&#65289;&#20381;&#28982;&#26159;&#28825;&#25163;&#21487;&#29105;&#30340;&#20154;&#25165;&#12290;</p><p>&#33287;&#21830;&#26989;&#25480;&#27402;&#30340; Matlab &#21644; SAS &#30456;&#36611;&#65292;R &#35486;&#35328;&#26159;&#20813;&#36027;&#36575;&#39636;&#25480;&#27402;&#65288;Free software license&#65289;&#65307;&#32780;&#33287;&#21516;&#28858;&#20813;&#36027;&#36575;&#39636;&#25480;&#27402;&#30340; Julia &#30456;&#36611;&#65292;R &#35486;&#35328;&#22312;&#29694;&#38542;&#27573;&#20855;&#20633;&#26356;&#24291;&#22823;&#30340;&#20351;&#29992;&#32773;&#31038;&#32676;&#65288;&#20197;&#38283;&#30332;&#32773;&#36002;&#29563;&#30340;&#22871;&#20214;&#25976;&#20358;&#27604;&#36611;&#65292;&#25130;&#33267; 2022 &#24180; 1 &#26376;&#65292;Julia &#30446;&#21069;&#26377;&#36229;&#36942;&#22235;&#21315;&#20491;&#22871;&#20214;&#12289;R &#21063;&#26377;&#36229;&#36942;&#19968;&#33836;&#20843;&#21315;&#20491;&#22871;&#20214;&#12290;R &#20197;&#20989;&#25976;&#22411;&#31243;&#24335;&#35373;&#35336;&#65288;Functional programming&#65289;&#33287;&#36039;&#26009;&#20998;&#26512;&#20316;&#28858;&#35373;&#35336;&#29702;&#24565;&#26680;&#24515;&#65292;&#22240;&#27492;&#22312;&#22905;&#30340;&#35222;&#37326;&#20013;&#65292;&#25152;&#26377;&#30340;&#36039;&#26009;&#65288;&#25991;&#23383;&#12289;&#25976;&#20540;&#25110;&#37007;&#36655;&#31561;&#65289;&#37117;&#19981;&#26159;&#20197;&#32020;&#37327;&#23384;&#22312;&#65292;&#32780;&#26159;&#20197;&#21521;&#37327;&#23384;&#22312;&#65292;&#36889;&#27171;&#30340;&#35373;&#35336;&#29702;&#24565;&#20351;&#24471;&#20803;&#32032;&#36939;&#31639;&#65288;Elementwise operation&#65289;&#23565; R &#35486;&#35328;&#20351;&#29992;&#32773;&#32780;&#35328;&#26159;&#29702;&#25152;&#30070;&#28982;&#30340;&#12290;&#31245;&#24494;&#26296;&#35299;&#20102; R &#35486;&#35328;&#30340;&#29305;&#24615;&#20043;&#24460;&#65292;&#23637;&#38283;&#23416;&#32722;&#26053;&#31243;&#30340;&#31532;&#19968;&#31449;&#26159; R &#35486;&#35328;&#30340;&#21704;&#22217;&#19990;&#30028;&#65281;</p><h2>R &#35486;&#35328;&#30340;&#21704;&#22217;&#19990;&#30028;</h2><p>&#12300;&#21704;&#22217;&#19990;&#30028;&#12301;&#26159;&#27599;&#31278;&#35486;&#35328;&#26368;&#22522;&#26412;&#20063;&#26368;&#31777;&#21934;&#30340;&#31243;&#24335;&#65292;&#36890;&#24120;&#29992;&#20316;&#30906;&#35469;&#19968;&#20491;&#35486;&#35328;&#22914;&#20309;&#36939;&#20316;&#12289;&#32232;&#35695;&#22120;&#12289;&#38283;&#30332;&#29872;&#22659;&#21450;&#22519;&#34892;&#29872;&#22659;&#26159;&#21542;&#24050;&#32147;&#23433;&#35037;&#22949;&#30070;&#12290;&#35201;&#38918;&#21033;&#36939;&#34892; R &#35486;&#35328;&#30340;&#21704;&#22217;&#19990;&#30028;&#20197;&#21450;&#26410;&#20358;&#30340; R &#35486;&#35328;&#36039;&#26009;&#31185;&#23416;&#25033;&#29992;&#65292;&#39318;&#20808;&#35201;&#30906;&#23450;&#22312; Jupyter &#26143;&#29699;&#30340;&#20282;&#26381;&#22120;&#36984;&#38917;&#36984;&#25799;&#20102;&#12300;Data science environment&#65306;&#23416;&#32722; Python&#12289;R &#33287; Julia &#30340;&#36039;&#26009;&#31185;&#23416;&#29872;&#22659;&#12301;&#12290;&#24536;&#35352;&#20102;&#20160;&#40636;&#26159; Jupyter &#26143;&#29699;&#21966;&#65311;&#35079;&#32722;&#19968;&#19979;<a href="https://datainpoint.substack.com/p/week-zero-welcome">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;&#27489;&#36814;&#20809;&#33256; Jupyter &#26143;&#29699;</a>&#21543;&#65281;</p><p>&#20282;&#26381;&#22120;&#21855;&#21205;&#20043;&#24460;&#20358;&#21040; Jupyter &#26143;&#29699;&#30340;&#39318;&#38913;&#65292;&#22312;&#21491;&#26041; Launcher &#40670;&#36984;&#26032;&#22686;&#19968;&#20491;&#26680;&#24515;&#65288;Kernel&#65289;&#28858; R &#30340; Jupyter Notebook&#12290;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!uuIQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F11a95e0c-2096-4723-bfd5-6b1814e5bde6_2570x1176.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!uuIQ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F11a95e0c-2096-4723-bfd5-6b1814e5bde6_2570x1176.png 424w, https://substackcdn.com/image/fetch/$s_!uuIQ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F11a95e0c-2096-4723-bfd5-6b1814e5bde6_2570x1176.png 848w, https://substackcdn.com/image/fetch/$s_!uuIQ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F11a95e0c-2096-4723-bfd5-6b1814e5bde6_2570x1176.png 1272w, https://substackcdn.com/image/fetch/$s_!uuIQ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F11a95e0c-2096-4723-bfd5-6b1814e5bde6_2570x1176.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!uuIQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F11a95e0c-2096-4723-bfd5-6b1814e5bde6_2570x1176.png" width="1456" height="666" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/11a95e0c-2096-4723-bfd5-6b1814e5bde6_2570x1176.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:666,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:311668,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!uuIQ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F11a95e0c-2096-4723-bfd5-6b1814e5bde6_2570x1176.png 424w, https://substackcdn.com/image/fetch/$s_!uuIQ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F11a95e0c-2096-4723-bfd5-6b1814e5bde6_2570x1176.png 848w, https://substackcdn.com/image/fetch/$s_!uuIQ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F11a95e0c-2096-4723-bfd5-6b1814e5bde6_2570x1176.png 1272w, https://substackcdn.com/image/fetch/$s_!uuIQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F11a95e0c-2096-4723-bfd5-6b1814e5bde6_2570x1176.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#26032;&#22686;&#19968;&#20491;&#26680;&#24515;&#65288;Kernel&#65289;&#28858; R &#30340; Jupyter Notebook</figcaption></figure></div><p>&#20006;&#19988;&#22312; Jupyter Notebook &#30340;&#31532;&#19968;&#20491;&#20786;&#23384;&#26684;&#20013;&#21360;&#20986; R &#30340;&#21704;&#22217;&#19990;&#30028;&#65306;</p><pre><code>print("Hello, World!")</code></pre><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!FM8z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F540db3a4-71f0-478b-98f6-13742b729bbd_2360x530.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!FM8z!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F540db3a4-71f0-478b-98f6-13742b729bbd_2360x530.png 424w, https://substackcdn.com/image/fetch/$s_!FM8z!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F540db3a4-71f0-478b-98f6-13742b729bbd_2360x530.png 848w, https://substackcdn.com/image/fetch/$s_!FM8z!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F540db3a4-71f0-478b-98f6-13742b729bbd_2360x530.png 1272w, https://substackcdn.com/image/fetch/$s_!FM8z!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F540db3a4-71f0-478b-98f6-13742b729bbd_2360x530.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!FM8z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F540db3a4-71f0-478b-98f6-13742b729bbd_2360x530.png" width="1456" height="327" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/540db3a4-71f0-478b-98f6-13742b729bbd_2360x530.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:327,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:135022,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!FM8z!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F540db3a4-71f0-478b-98f6-13742b729bbd_2360x530.png 424w, https://substackcdn.com/image/fetch/$s_!FM8z!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F540db3a4-71f0-478b-98f6-13742b729bbd_2360x530.png 848w, https://substackcdn.com/image/fetch/$s_!FM8z!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F540db3a4-71f0-478b-98f6-13742b729bbd_2360x530.png 1272w, https://substackcdn.com/image/fetch/$s_!FM8z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F540db3a4-71f0-478b-98f6-13742b729bbd_2360x530.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h2>&#25972;&#21512;&#38283;&#30332;&#29872;&#22659; RStudio &#20171;&#38754;</h2><p>&#20063;&#21487;&#20197;&#22312; Jupyter &#26143;&#29699;&#21855;&#21205; R &#35486;&#35328;&#24859;&#22909;&#32773;&#24456;&#21916;&#27489;&#30340;&#25972;&#21512;&#38283;&#30332;&#29872;&#22659; RStudio&#12290;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!nXWx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fbaca1d64-3411-47bc-b955-16e506aa1150_2392x1170.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nXWx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fbaca1d64-3411-47bc-b955-16e506aa1150_2392x1170.png 424w, https://substackcdn.com/image/fetch/$s_!nXWx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fbaca1d64-3411-47bc-b955-16e506aa1150_2392x1170.png 848w, https://substackcdn.com/image/fetch/$s_!nXWx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fbaca1d64-3411-47bc-b955-16e506aa1150_2392x1170.png 1272w, https://substackcdn.com/image/fetch/$s_!nXWx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fbaca1d64-3411-47bc-b955-16e506aa1150_2392x1170.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!nXWx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fbaca1d64-3411-47bc-b955-16e506aa1150_2392x1170.png" width="1456" height="712" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/baca1d64-3411-47bc-b955-16e506aa1150_2392x1170.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:712,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:286701,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!nXWx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fbaca1d64-3411-47bc-b955-16e506aa1150_2392x1170.png 424w, https://substackcdn.com/image/fetch/$s_!nXWx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fbaca1d64-3411-47bc-b955-16e506aa1150_2392x1170.png 848w, https://substackcdn.com/image/fetch/$s_!nXWx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fbaca1d64-3411-47bc-b955-16e506aa1150_2392x1170.png 1272w, https://substackcdn.com/image/fetch/$s_!nXWx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fbaca1d64-3411-47bc-b955-16e506aa1150_2392x1170.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#22312; Jupyter &#26143;&#29699;&#21855;&#21205;&#25972;&#21512;&#38283;&#30332;&#29872;&#22659; RStudio</figcaption></figure></div><p>&#25972;&#21512;&#38283;&#30332;&#29872;&#22659; RStudio &#20171;&#38754;&#26371;&#39023;&#31034;&#19977;&#20491;&#21312;&#22602;&#12290;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Z2Hy!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd76c2a19-3f8f-48c9-b65f-2f5867bfcd5b_1750x930.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Z2Hy!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd76c2a19-3f8f-48c9-b65f-2f5867bfcd5b_1750x930.png 424w, https://substackcdn.com/image/fetch/$s_!Z2Hy!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd76c2a19-3f8f-48c9-b65f-2f5867bfcd5b_1750x930.png 848w, https://substackcdn.com/image/fetch/$s_!Z2Hy!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd76c2a19-3f8f-48c9-b65f-2f5867bfcd5b_1750x930.png 1272w, https://substackcdn.com/image/fetch/$s_!Z2Hy!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd76c2a19-3f8f-48c9-b65f-2f5867bfcd5b_1750x930.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Z2Hy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd76c2a19-3f8f-48c9-b65f-2f5867bfcd5b_1750x930.png" width="1456" height="774" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/d76c2a19-3f8f-48c9-b65f-2f5867bfcd5b_1750x930.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:774,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!Z2Hy!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd76c2a19-3f8f-48c9-b65f-2f5867bfcd5b_1750x930.png 424w, https://substackcdn.com/image/fetch/$s_!Z2Hy!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd76c2a19-3f8f-48c9-b65f-2f5867bfcd5b_1750x930.png 848w, https://substackcdn.com/image/fetch/$s_!Z2Hy!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd76c2a19-3f8f-48c9-b65f-2f5867bfcd5b_1750x930.png 1272w, https://substackcdn.com/image/fetch/$s_!Z2Hy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd76c2a19-3f8f-48c9-b65f-2f5867bfcd5b_1750x930.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#31532;&#19968;&#27425;&#22519;&#34892; RStudio &#20171;&#38754;&#26371;&#39023;&#31034;&#19977;&#20491;&#21312;&#22602;</figcaption></figure></div><p>&#36879;&#36942;&#40670;&#36984;&#26032;&#22686;&#19968;&#20491; R &#31243;&#24335;&#30908;&#27284;&#26696;&#65288;R Script&#65289;&#23559;&#23436;&#25972;&#30340;&#22235;&#20491;&#21312;&#22602;&#37117;&#39023;&#31034;&#20986;&#20358;&#12290;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!slwo!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F31566df0-b8a7-4081-91da-b5d6c3748aac_1340x706.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!slwo!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F31566df0-b8a7-4081-91da-b5d6c3748aac_1340x706.png 424w, https://substackcdn.com/image/fetch/$s_!slwo!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F31566df0-b8a7-4081-91da-b5d6c3748aac_1340x706.png 848w, https://substackcdn.com/image/fetch/$s_!slwo!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F31566df0-b8a7-4081-91da-b5d6c3748aac_1340x706.png 1272w, https://substackcdn.com/image/fetch/$s_!slwo!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F31566df0-b8a7-4081-91da-b5d6c3748aac_1340x706.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!slwo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F31566df0-b8a7-4081-91da-b5d6c3748aac_1340x706.png" width="1340" height="706" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/31566df0-b8a7-4081-91da-b5d6c3748aac_1340x706.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:706,&quot;width&quot;:1340,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!slwo!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F31566df0-b8a7-4081-91da-b5d6c3748aac_1340x706.png 424w, https://substackcdn.com/image/fetch/$s_!slwo!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F31566df0-b8a7-4081-91da-b5d6c3748aac_1340x706.png 848w, https://substackcdn.com/image/fetch/$s_!slwo!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F31566df0-b8a7-4081-91da-b5d6c3748aac_1340x706.png 1272w, https://substackcdn.com/image/fetch/$s_!slwo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F31566df0-b8a7-4081-91da-b5d6c3748aac_1340x706.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#26032;&#22686;&#19968;&#20491; R &#31243;&#24335;&#30908;&#27284;&#26696;&#65288;R Script&#65289;</figcaption></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HE-k!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F689a1f93-d7b2-48c7-881e-20f92aa6af12_1341x708.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HE-k!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F689a1f93-d7b2-48c7-881e-20f92aa6af12_1341x708.png 424w, https://substackcdn.com/image/fetch/$s_!HE-k!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F689a1f93-d7b2-48c7-881e-20f92aa6af12_1341x708.png 848w, https://substackcdn.com/image/fetch/$s_!HE-k!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F689a1f93-d7b2-48c7-881e-20f92aa6af12_1341x708.png 1272w, https://substackcdn.com/image/fetch/$s_!HE-k!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F689a1f93-d7b2-48c7-881e-20f92aa6af12_1341x708.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!HE-k!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F689a1f93-d7b2-48c7-881e-20f92aa6af12_1341x708.png" width="1341" height="708" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/689a1f93-d7b2-48c7-881e-20f92aa6af12_1341x708.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:708,&quot;width&quot;:1341,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!HE-k!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F689a1f93-d7b2-48c7-881e-20f92aa6af12_1341x708.png 424w, https://substackcdn.com/image/fetch/$s_!HE-k!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F689a1f93-d7b2-48c7-881e-20f92aa6af12_1341x708.png 848w, https://substackcdn.com/image/fetch/$s_!HE-k!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F689a1f93-d7b2-48c7-881e-20f92aa6af12_1341x708.png 1272w, https://substackcdn.com/image/fetch/$s_!HE-k!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F689a1f93-d7b2-48c7-881e-20f92aa6af12_1341x708.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#23436;&#25972;&#30340;&#22235;&#20491;&#21312;&#22602;&#37117;&#39023;&#31034;&#20986;&#20358;</figcaption></figure></div><p>RStudio &#20171;&#38754;&#20027;&#35201;&#30340;&#22235;&#20491;&#21312;&#22602;&#33287;&#21151;&#33021;&#31777;&#20171;&#65306;</p><ol><li><p>&#20358;&#28304;&#65288;Source&#65289;&#65306;&#20301;&#26044;&#24038;&#19978;&#35282;&#65292;&#32232;&#23531;&#31243;&#24335;&#30340;&#21312;&#22602;&#12290;</p></li><li><p>&#21629;&#20196;&#21015;&#65288;Console&#65289;&#65306;&#20301;&#26044;&#24038;&#19979;&#35282;&#65292;&#22519;&#34892;&#31243;&#24335;&#19988;&#21576;&#29694;&#36664;&#20986;&#30340;&#21312;&#22602;&#12290;</p></li><li><p>&#29872;&#22659;&#33287;&#27511;&#21490;&#65306;&#20301;&#26044;&#21491;&#19978;&#35282;&#65292;&#20854;&#20013;&#29872;&#22659;&#65288;Environment&#65289;&#26371;&#39023;&#31034;&#20986;&#30446;&#21069;&#21487;&#20197;&#21462;&#29992;&#30340;&#20540;&#65288;Values&#65289;&#12289;&#36039;&#26009;&#65288;Data&#65289;&#33287;&#20989;&#25976;&#65288;Functions&#65289;&#65307;&#27511;&#21490;&#65288;History&#65289;&#26371;&#39023;&#31034;&#22312;&#21629;&#20196;&#21015;&#22519;&#34892;&#36942;&#21738;&#20123;&#25351;&#20196;&#12290;</p></li><li><p>&#27284;&#26696;&#12289;&#22294;&#24418;&#12289;&#22871;&#20214;&#12289;&#26597;&#35426;&#33287;&#38928;&#35261;&#22120;&#65306;&#20301;&#26044;&#21491;&#19979;&#35282;&#65292;&#20854;&#20013;&#27284;&#26696;&#65288;Files&#65289;&#26371;&#39023;&#31034; R &#35486;&#35328;&#25152;&#22312;&#30340;&#24037;&#20316;&#30446;&#37636;&#65288;Working Directory&#65289;&#12289;&#22294;&#24418;&#65288;Plots&#65289;&#21063;&#33021;&#28687;&#35261;&#35258;&#21270;&#22294;&#24418;&#12289;&#22871;&#20214;&#65288;Packages&#65289;&#21487;&#20197;&#35264;&#23519;&#22871;&#20214;&#23433;&#35037;&#33287;&#36617;&#20837;&#29694;&#27841;&#12289;&#26597;&#35426;&#65288;Help&#65289;&#33021;&#22816;&#27298;&#35222;&#20351;&#29992;&#32773;&#26597;&#35426;&#30340;&#25991;&#20214;&#20197;&#21450;&#38928;&#35261;&#22120;&#65288;Viewer&#65289;&#26159;&#38928;&#35261;&#32178;&#38913;&#30340;&#36664;&#20986;&#32080;&#26524;&#12290;</p></li></ol><p>&#38626;&#38283; RStudio &#30340;&#26041;&#24335;&#21487;&#20197;&#25505;&#29992;&#40670;&#25802;&#35222;&#31383;&#21491;&#19978;&#35282;&#30340;&#38651;&#28304;&#22294;&#31034;&#38626;&#38283;&#25110;&#32773;&#22312;&#21629;&#20196;&#21015;&#36664;&#20837; <code>q()</code> &#24460;&#25353;&#19979; Enter&#65292;&#38626;&#38283;&#26178;&#33509;&#26159;&#29872;&#22659;&#20013;&#26377;&#36039;&#26009;&#23384;&#22312;&#26371;&#35426;&#21839;&#26159;&#21542;&#35201;&#20786;&#23384;&#24037;&#20316;&#31354;&#38291;&#65292;&#22914;&#26524;&#24076;&#26395;&#19979;&#19968;&#27425;&#21855;&#21205;&#26178;&#20445;&#26377;&#30446;&#21069;&#29872;&#22659;&#20013;&#30340;&#29289;&#20214;&#65292;&#21487;&#20197;&#36984;&#25799;&#20786;&#23384;&#24037;&#20316;&#31354;&#38291;&#65292;&#20294;&#22810;&#25976;&#30340; R &#35486;&#35328;&#20351;&#29992;&#32773;&#19981;&#26371;&#20786;&#23384;&#24037;&#20316;&#31354;&#38291;&#12290;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Y2JN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4a3e871b-d88e-46b2-b6a3-7e8aa62c989e_1340x707.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Y2JN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4a3e871b-d88e-46b2-b6a3-7e8aa62c989e_1340x707.png 424w, https://substackcdn.com/image/fetch/$s_!Y2JN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4a3e871b-d88e-46b2-b6a3-7e8aa62c989e_1340x707.png 848w, https://substackcdn.com/image/fetch/$s_!Y2JN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4a3e871b-d88e-46b2-b6a3-7e8aa62c989e_1340x707.png 1272w, https://substackcdn.com/image/fetch/$s_!Y2JN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4a3e871b-d88e-46b2-b6a3-7e8aa62c989e_1340x707.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Y2JN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4a3e871b-d88e-46b2-b6a3-7e8aa62c989e_1340x707.png" width="1340" height="707" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/4a3e871b-d88e-46b2-b6a3-7e8aa62c989e_1340x707.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:707,&quot;width&quot;:1340,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!Y2JN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4a3e871b-d88e-46b2-b6a3-7e8aa62c989e_1340x707.png 424w, https://substackcdn.com/image/fetch/$s_!Y2JN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4a3e871b-d88e-46b2-b6a3-7e8aa62c989e_1340x707.png 848w, https://substackcdn.com/image/fetch/$s_!Y2JN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4a3e871b-d88e-46b2-b6a3-7e8aa62c989e_1340x707.png 1272w, https://substackcdn.com/image/fetch/$s_!Y2JN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4a3e871b-d88e-46b2-b6a3-7e8aa62c989e_1340x707.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#38626;&#38283;&#20006;&#19988;&#19981;&#20786;&#23384;&#24037;&#20316;&#31354;&#38291;</figcaption></figure></div><h2><strong>&#25361;&#36984; RStudio &#20296;&#26223;&#20027;&#38988;&#33394;&#24425;</strong></h2><p>&#25972;&#21512;&#38283;&#30332;&#29872;&#22659; RStudio &#33021;&#22816;&#20570;&#30340;&#35373;&#23450;&#38750;&#24120;&#22810;&#65292;&#36890;&#24120;&#21021;&#23416;&#32773;&#19968;&#38283;&#22987;&#26368;&#38656;&#35201;&#20570;&#30340;&#26159;&#25361;&#36984;&#19968;&#20491;&#33258;&#24049;&#21916;&#27489;&#30340; RStudio &#20296;&#26223;&#20027;&#38988;&#65292;&#36879;&#36942;&#40670;&#36984;&#24037;&#20855;&#21015; Tools -&gt; Global Options &#23601;&#33021;&#22816;&#22312; Appearance &#38913;&#31844;&#36984;&#25799;&#19968;&#20491;&#20559;&#24859;&#30340;&#20296;&#26223;&#20027;&#38988;&#33394;&#24425;&#65292;&#38263;&#26178;&#38291;&#30447;&#33879;&#38651;&#33126;&#34722;&#24149;&#30340;&#20351;&#29992;&#32773;&#36890;&#24120;&#20559;&#22909;&#20351;&#29992;&#28145;&#33394;&#32972;&#26223;&#28187;&#23569;&#21050;&#30524;&#24863;&#35258;&#12290;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!OBDy!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F86aa68eb-b2f7-455f-a79b-6c4a955c06fe_1344x732.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OBDy!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F86aa68eb-b2f7-455f-a79b-6c4a955c06fe_1344x732.png 424w, https://substackcdn.com/image/fetch/$s_!OBDy!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F86aa68eb-b2f7-455f-a79b-6c4a955c06fe_1344x732.png 848w, https://substackcdn.com/image/fetch/$s_!OBDy!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F86aa68eb-b2f7-455f-a79b-6c4a955c06fe_1344x732.png 1272w, https://substackcdn.com/image/fetch/$s_!OBDy!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F86aa68eb-b2f7-455f-a79b-6c4a955c06fe_1344x732.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!OBDy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F86aa68eb-b2f7-455f-a79b-6c4a955c06fe_1344x732.png" width="1344" height="732" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/86aa68eb-b2f7-455f-a79b-6c4a955c06fe_1344x732.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:732,&quot;width&quot;:1344,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!OBDy!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F86aa68eb-b2f7-455f-a79b-6c4a955c06fe_1344x732.png 424w, https://substackcdn.com/image/fetch/$s_!OBDy!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F86aa68eb-b2f7-455f-a79b-6c4a955c06fe_1344x732.png 848w, https://substackcdn.com/image/fetch/$s_!OBDy!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F86aa68eb-b2f7-455f-a79b-6c4a955c06fe_1344x732.png 1272w, https://substackcdn.com/image/fetch/$s_!OBDy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F86aa68eb-b2f7-455f-a79b-6c4a955c06fe_1344x732.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#40670;&#36984;&#24037;&#20855;&#21015; Tools -&gt; Global Options</figcaption></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!gj95!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fec726210-545f-4e8b-90c8-4efba0551a1b_1172x1158.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!gj95!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fec726210-545f-4e8b-90c8-4efba0551a1b_1172x1158.png 424w, https://substackcdn.com/image/fetch/$s_!gj95!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fec726210-545f-4e8b-90c8-4efba0551a1b_1172x1158.png 848w, https://substackcdn.com/image/fetch/$s_!gj95!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fec726210-545f-4e8b-90c8-4efba0551a1b_1172x1158.png 1272w, https://substackcdn.com/image/fetch/$s_!gj95!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fec726210-545f-4e8b-90c8-4efba0551a1b_1172x1158.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!gj95!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fec726210-545f-4e8b-90c8-4efba0551a1b_1172x1158.png" width="1172" height="1158" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/ec726210-545f-4e8b-90c8-4efba0551a1b_1172x1158.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1158,&quot;width&quot;:1172,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!gj95!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fec726210-545f-4e8b-90c8-4efba0551a1b_1172x1158.png 424w, https://substackcdn.com/image/fetch/$s_!gj95!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fec726210-545f-4e8b-90c8-4efba0551a1b_1172x1158.png 848w, https://substackcdn.com/image/fetch/$s_!gj95!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fec726210-545f-4e8b-90c8-4efba0551a1b_1172x1158.png 1272w, https://substackcdn.com/image/fetch/$s_!gj95!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fec726210-545f-4e8b-90c8-4efba0551a1b_1172x1158.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#22312; Appearance &#38913;&#31844;&#36984;&#25799;&#19968;&#20491;&#20559;&#24859;&#30340;&#20296;&#26223;&#20027;&#38988;&#33394;&#24425;</figcaption></figure></div><p>&#22823;&#21151;&#21578;&#25104;&#65292;&#22312;&#38918;&#21033;&#22519;&#34892;&#20102; R &#35486;&#35328;&#30340;&#21704;&#22217;&#19990;&#30028;&#20197;&#21450;&#36984;&#25799;&#21916;&#24859;&#30340; RStudio &#20296;&#26223;&#20027;&#38988;&#20043;&#24460;&#65292;&#31532;&#20108;&#21313;&#19977;&#36913;&#30340;&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;R &#35486;&#35328;&#36215;&#27493;&#36208;&#20358;&#21040;&#23614;&#32882;&#65292;&#24076;&#26395;&#24744;&#20063;&#21644;&#25105;&#19968;&#27171;&#26399;&#24453;&#19979;&#19968;&#31687;&#25991;&#31456;&#12290;</p><div><hr></div><p>&#23565;&#26044;&#36889;&#31687;&#25991;&#31456;&#26377;&#20160;&#40636;&#24819;&#27861;&#21602;&#65311;&#21916;&#27489;&#128571;&#12289;&#30041;&#35328;&#128587;&#8205;&#9794;&#65039;&#25110;&#32773;&#20998;&#20139;&#128588;</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://datainpoint.substack.com/p/week-twenty-three-getting-started-with-r/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://datainpoint.substack.com/p/week-twenty-three-getting-started-with-r/comments"><span>Leave a comment</span></a></p><h2>&#24310;&#20280;&#38321;&#35712;</h2><ul><li><p><a href="https://www.tiobe.com/tiobe-index">https://www.tiobe.com/tiobe-index</a></p></li><li><p><a href="https://spectrum.ieee.org/top-programming-languages">https://spectrum.ieee.org/top-programming-languages</a></p></li></ul>]]></content:encoded></item><item><title><![CDATA[約維安計畫：中級約維安的第二個里程碑專案]]></title><description><![CDATA[&#31532;&#20108;&#21313;&#20108;&#36913;]]></description><link>https://datainpoint.substack.com/p/week-twenty-two-milestone-project</link><guid isPermaLink="false">https://datainpoint.substack.com/p/week-twenty-two-milestone-project</guid><dc:creator><![CDATA[Yao-Jen Kuo]]></dc:creator><pubDate>Fri, 26 Nov 2021 13:27:54 GMT</pubDate><enclosure url="https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/260f8dc6-fa2f-4754-a74b-f35b94b572ab_480x270.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!DhNx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8e77c06-ae74-4a6e-8d70-8b27a455555f_480x270.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!DhNx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8e77c06-ae74-4a6e-8d70-8b27a455555f_480x270.gif 424w, https://substackcdn.com/image/fetch/$s_!DhNx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8e77c06-ae74-4a6e-8d70-8b27a455555f_480x270.gif 848w, https://substackcdn.com/image/fetch/$s_!DhNx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8e77c06-ae74-4a6e-8d70-8b27a455555f_480x270.gif 1272w, https://substackcdn.com/image/fetch/$s_!DhNx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8e77c06-ae74-4a6e-8d70-8b27a455555f_480x270.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!DhNx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8e77c06-ae74-4a6e-8d70-8b27a455555f_480x270.gif" width="480" height="270" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/a8e77c06-ae74-4a6e-8d70-8b27a455555f_480x270.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:270,&quot;width&quot;:480,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1311975,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!DhNx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8e77c06-ae74-4a6e-8d70-8b27a455555f_480x270.gif 424w, https://substackcdn.com/image/fetch/$s_!DhNx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8e77c06-ae74-4a6e-8d70-8b27a455555f_480x270.gif 848w, https://substackcdn.com/image/fetch/$s_!DhNx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8e77c06-ae74-4a6e-8d70-8b27a455555f_480x270.gif 1272w, https://substackcdn.com/image/fetch/$s_!DhNx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8e77c06-ae74-4a6e-8d70-8b27a455555f_480x270.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#20358;&#28304;&#65306;<a href="https://giphy.com">giphy.com</a></figcaption></figure></div><p>&#32004;&#32173;&#23433;&#35336;&#30059;&#21363;&#23559;&#36814;&#20358;&#31532;&#19977;&#20491;&#37324;&#31243;&#30865;&#23560;&#26696;&#65281;&#24478;&#31532;&#21313;&#20108;&#36913;&#21040;&#31532;&#20108;&#21313;&#19968;&#36913;&#65292;&#25105;&#20497;&#24478; Python &#36215;&#27493;&#36208;&#21040;&#20102;&#36914;&#38542;&#25216;&#24039;&#65292;&#20006;&#19988;&#23436;&#25104;&#20102;&#19977;&#20221;&#22522;&#26044;&#20027;&#38988;&#30340;&#32244;&#32722;&#38988;&#65292;&#26296;&#35299;&#22914;&#20309;&#22312; Jupyter &#26143;&#29699;&#23416;&#32722;&#20006;&#19988;&#32244;&#32722; Python&#12290;</p><p>&#36879;&#36942;&#36889;&#20491;&#37324;&#31243;&#30865;&#23560;&#26696;&#65292;&#27491;&#26159;&#35731;&#25105;&#20497;&#35079;&#32722;&#19968;&#19979;&#36889;&#21313;&#36913;&#23416;&#32722;&#25991;&#31456;&#30340;&#22909;&#27231;&#26371;&#65281;</p><ol><li><p><a href="https://datainpoint.substack.com/p/week-twelve-getting-started-with-python">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#36215;&#27493;&#36208;</a></p></li><li><p><a href="https://datainpoint.substack.com/p/week-thirteen-functions-and-data-types-in-python">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#30340;&#36039;&#26009;&#22411;&#21029;</a></p></li><li><p><a href="https://datainpoint.substack.com/p/week-fourteen-data-structures-in-python">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#30340;&#36039;&#26009;&#32080;&#27083;</a></p></li><li><p><a href="https://datainpoint.substack.com/p/week-fifteen-control-flow-in-python">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#30340;&#27969;&#31243;&#25511;&#21046;</a></p></li><li><p><a href="https://datainpoint.substack.com/p/week-sixteen-functions-in-python">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#30340;&#20989;&#25976;</a></p></li><li><p><a href="https://datainpoint.substack.com/p/week-seventeen-classes-in-python">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#30340;&#39006;&#21029;</a></p></li><li><p><a href="https://datainpoint.substack.com/p/week-eighteen-modules-in-python">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#30340;&#27169;&#32068;</a></p></li><li><p><a href="https://datainpoint.substack.com/p/week-nineteen-python-tips">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#25216;&#24039;</a></p></li><li><p><a href="https://datainpoint.substack.com/p/week-twenty-python-exercises">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#36039;&#26009;&#32080;&#27083;&#33287;&#27969;&#31243;&#25511;&#21046;&#32244;&#32722;&#38988;</a></p></li><li><p><a href="https://datainpoint.substack.com/p/week-twenty-one-python-exercises">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#20989;&#25976;&#12289;&#39006;&#21029;&#12289;&#27169;&#32068;&#33287;&#25216;&#24039;&#32244;&#32722;&#38988;</a></p></li></ol><h2>&#37324;&#31243;&#30865;&#23560;&#26696;</h2><p>&#40670;&#25802;&#31532;&#20108;&#21313;&#20108;&#36913;&#30340;&#36039;&#26009;&#22846;&#36899;&#32080;&#65306;<a href="https://lab.datainpoint.com/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fdatainpoint%2Fweek-twenty-two-milestone-project&amp;urlpath=tree%2Fweek-twenty-two-milestone-project%2Fexercises.ipynb&amp;branch=main">&#31532;&#20108;&#21313;&#20108;&#36913;&#30340;&#23560;&#26696;&#36039;&#26009;&#22846;</a>&#12290;</p>
      <p>
          <a href="https://datainpoint.substack.com/p/week-twenty-two-milestone-project">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[約維安計畫：Python 函數、類別、模組與技巧練習題]]></title><description><![CDATA[&#31532;&#20108;&#21313;&#19968;&#36913;]]></description><link>https://datainpoint.substack.com/p/week-twenty-one-python-exercises</link><guid isPermaLink="false">https://datainpoint.substack.com/p/week-twenty-one-python-exercises</guid><dc:creator><![CDATA[Yao-Jen Kuo]]></dc:creator><pubDate>Thu, 04 Nov 2021 05:00:46 GMT</pubDate><enclosure url="https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/f7723bf6-0883-4942-9f08-f4c059fe4a26_450x253.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!sVLl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F3347b48f-eceb-4411-baf5-dc8086330e77_450x253.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!sVLl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F3347b48f-eceb-4411-baf5-dc8086330e77_450x253.gif 424w, https://substackcdn.com/image/fetch/$s_!sVLl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F3347b48f-eceb-4411-baf5-dc8086330e77_450x253.gif 848w, https://substackcdn.com/image/fetch/$s_!sVLl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F3347b48f-eceb-4411-baf5-dc8086330e77_450x253.gif 1272w, https://substackcdn.com/image/fetch/$s_!sVLl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F3347b48f-eceb-4411-baf5-dc8086330e77_450x253.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!sVLl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F3347b48f-eceb-4411-baf5-dc8086330e77_450x253.gif" width="450" height="253" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/3347b48f-eceb-4411-baf5-dc8086330e77_450x253.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:253,&quot;width&quot;:450,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:997384,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!sVLl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F3347b48f-eceb-4411-baf5-dc8086330e77_450x253.gif 424w, https://substackcdn.com/image/fetch/$s_!sVLl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F3347b48f-eceb-4411-baf5-dc8086330e77_450x253.gif 848w, https://substackcdn.com/image/fetch/$s_!sVLl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F3347b48f-eceb-4411-baf5-dc8086330e77_450x253.gif 1272w, https://substackcdn.com/image/fetch/$s_!sVLl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F3347b48f-eceb-4411-baf5-dc8086330e77_450x253.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#20358;&#28304;&#65306;giphy.com</figcaption></figure></div><p>&#24478;&#31532;&#21313;&#20108;&#36913;&#21040;&#31532;&#21313;&#20061;&#36913;&#65292;&#25105;&#20497;&#24478; Python &#36215;&#27493;&#36208;&#21040; Python &#25216;&#24039;&#65292;&#20013;&#32026;&#32004;&#32173;&#23433;&#24050;&#32147;&#20855;&#20633;&#20102; Python &#22522;&#30990;&#30340;&#31243;&#24335;&#35373;&#35336;&#33021;&#21147;&#65292;&#26412;&#36913;&#32004;&#32173;&#23433;&#35336;&#30059;&#23433;&#25490;&#33287; Python &#20989;&#25976;&#12289;&#39006;&#21029;&#12289;&#27169;&#32068;&#33287;&#25216;&#24039;&#36889;&#22235;&#20491;&#20027;&#38988;&#30456;&#38364;&#30340;&#32244;&#32722;&#38988;&#12290;</p><p>&#24536;&#35352;&#20102;&#20160;&#40636;&#26159; Python &#20989;&#25976;&#12289;&#39006;&#21029;&#12289;&#27169;&#32068;&#33287;&#25216;&#24039;&#21966;&#65311;&#19981;&#35201;&#32202;&#65292;&#36879;&#36942;&#26412;&#36913;&#30340;&#32244;&#32722;&#38988;&#65292;&#27491;&#26159;&#35731;&#25105;&#20497;&#35079;&#32722;&#19968;&#19979;&#36889;&#20841;&#36913;&#23416;&#32722;&#25991;&#31456;&#30340;&#22909;&#27231;&#26371;&#65281;</p><ol><li><p><a href="https://datainpoint.substack.com/p/week-sixteen-functions-in-python">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#30340;&#20989;&#25976;</a>&#12290;</p></li><li><p><a href="https://datainpoint.substack.com/p/week-seventeen-classes-in-python">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#30340;&#39006;&#21029;</a>&#12290;</p></li><li><p><a href="https://datainpoint.substack.com/p/week-eighteen-modules-in-python">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#30340;&#27169;&#32068;</a>&#12290;</p></li><li><p><a href="https://datainpoint.substack.com/p/week-nineteen-python-tips">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#25216;&#24039;</a>&#12290;</p></li></ol><h2>&#32244;&#32722;&#38988;</h2><p>&#40670;&#25802;&#31532;&#20108;&#21313;&#19968;&#36913;&#30340;&#36039;&#26009;&#22846;&#36899;&#32080;&#65306;</p><p><a href="https://lab.datainpoint.com/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fdatainpoint%2Fweek-twenty-one-python-function-class-module-tips-exercises&amp;urlpath=tree%2Fweek-twenty-one-python-function-class-module-tips-exercises%2Fexercises.ipynb&amp;branch=main">&#31532;&#20108;&#21313;&#19968;&#36913;&#30340;&#36039;&#26009;&#22846;&#36899;&#32080;</a></p><p>&#40670;&#25802;&#36899;&#32080;&#20043;&#24460;&#23559;&#26371;&#35079;&#35069;&#19968;&#20221;&#23560;&#26696;&#36039;&#26009;&#22846;&#21040; Jupyter &#26143;&#29699;&#30340;&#39318;&#38913;&#65292;&#38283;&#21855;&#36889;&#20491;&#36039;&#26009;&#22846;&#25105;&#20497;&#21487;&#20197;&#30475;&#21040;&#22235;&#20491;&#27284;&#26696;&#65306;</p><ul><li><p>README.md</p></li><li><p>exercises.ipynb</p></li><li><p>sugges&#8230;</p></li></ul>
      <p>
          <a href="https://datainpoint.substack.com/p/week-twenty-one-python-exercises">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[約維安計畫：Python 資料結構與流程控制練習題]]></title><description><![CDATA[&#31532;&#20108;&#21313;&#36913;]]></description><link>https://datainpoint.substack.com/p/week-twenty-python-exercises</link><guid isPermaLink="false">https://datainpoint.substack.com/p/week-twenty-python-exercises</guid><dc:creator><![CDATA[Yao-Jen Kuo]]></dc:creator><pubDate>Tue, 19 Oct 2021 08:44:55 GMT</pubDate><enclosure url="https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/c1afc670-8efa-4327-aee9-a988ab9fa4de_480x268.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!sfBh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F0faf3b46-4c15-4555-9240-ff99d715bcbe_480x268.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!sfBh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F0faf3b46-4c15-4555-9240-ff99d715bcbe_480x268.gif 424w, https://substackcdn.com/image/fetch/$s_!sfBh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F0faf3b46-4c15-4555-9240-ff99d715bcbe_480x268.gif 848w, https://substackcdn.com/image/fetch/$s_!sfBh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F0faf3b46-4c15-4555-9240-ff99d715bcbe_480x268.gif 1272w, https://substackcdn.com/image/fetch/$s_!sfBh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F0faf3b46-4c15-4555-9240-ff99d715bcbe_480x268.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!sfBh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F0faf3b46-4c15-4555-9240-ff99d715bcbe_480x268.gif" width="480" height="268" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/0faf3b46-4c15-4555-9240-ff99d715bcbe_480x268.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:268,&quot;width&quot;:480,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:150755,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!sfBh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F0faf3b46-4c15-4555-9240-ff99d715bcbe_480x268.gif 424w, https://substackcdn.com/image/fetch/$s_!sfBh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F0faf3b46-4c15-4555-9240-ff99d715bcbe_480x268.gif 848w, https://substackcdn.com/image/fetch/$s_!sfBh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F0faf3b46-4c15-4555-9240-ff99d715bcbe_480x268.gif 1272w, https://substackcdn.com/image/fetch/$s_!sfBh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F0faf3b46-4c15-4555-9240-ff99d715bcbe_480x268.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#20358;&#28304;&#65306;giphy.com</figcaption></figure></div><p>&#24478;&#31532;&#21313;&#20108;&#36913;&#21040;&#31532;&#21313;&#20061;&#36913;&#65292;&#25105;&#20497;&#24478; Python &#36215;&#27493;&#36208;&#21040; Python &#25216;&#24039;&#65292;&#20013;&#32026;&#32004;&#32173;&#23433;&#24050;&#32147;&#20855;&#20633;&#20102; Python &#22522;&#30990;&#30340;&#31243;&#24335;&#35373;&#35336;&#33021;&#21147;&#65292;&#26412;&#36913;&#32004;&#32173;&#23433;&#35336;&#30059;&#23433;&#25490;&#33287; Python &#36039;&#26009;&#32080;&#27083;&#21644;&#27969;&#31243;&#25511;&#21046;&#36889;&#20841;&#20491;&#20027;&#38988;&#30456;&#38364;&#30340;&#32244;&#32722;&#38988;&#12290;</p><p>&#24536;&#35352;&#20102;&#20160;&#40636;&#26159; Python &#36039;&#26009;&#32080;&#27083;&#21644;&#27969;&#31243;&#25511;&#21046;&#21966;&#65311;&#19981;&#35201;&#32202;&#65292;&#36879;&#36942;&#26412;&#36913;&#30340;&#32244;&#32722;&#38988;&#65292;&#27491;&#26159;&#35731;&#25105;&#20497;&#35079;&#32722;&#19968;&#19979;&#36889;&#20841;&#36913;&#23416;&#32722;&#25991;&#31456;&#30340;&#22909;&#27231;&#26371;&#65281;</p><ol><li><p><a href="https://datainpoint.substack.com/p/week-fourteen-data-structures-in-python">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#30340;&#36039;&#26009;&#32080;&#27083;</a>&#12290;</p></li><li><p><a href="https://datainpoint.substack.com/p/week-fifteen-control-flow-in-python">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#30340;&#27969;&#31243;&#25511;&#21046;</a>&#12290;</p></li></ol><h2>&#32244;&#32722;&#38988;</h2><p>&#40670;&#25802;&#31532;&#20108;&#21313;&#36913;&#30340;&#36039;&#26009;&#22846;&#36899;&#32080;&#65306;</p><p><a href="https://lab.datainpoint.com/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fdatainpoint%2Fweek-twenty-python-data-structure-control-flow-exercises&amp;urlpath=tree%2Fweek-twenty-python-data-structure-control-flow-exercises%2F&amp;branch=main">&#31532;&#20108;&#21313;&#36913;&#30340;&#36039;&#26009;&#22846;&#36899;&#32080;</a></p><p>&#40670;&#25802;&#36899;&#32080;&#20043;&#24460;&#23559;&#26371;&#35079;&#35069;&#19968;&#20221;&#23560;&#26696;&#36039;&#26009;&#22846;&#21040; Jupyter &#26143;&#29699;&#30340;&#39318;&#38913;&#65292;&#38283;&#21855;&#36889;&#20491;&#36039;&#26009;&#22846;&#25105;&#20497;&#21487;&#20197;&#30475;&#21040;&#19977;&#20491;&#27284;&#26696;&#65306;</p><ul><li><p>README.md</p></li><li><p>exercises.ipynb</p></li><li><p>suggested_answers.ipynb</p></li></ul><p>&#35201;&#38918;&#21033;&#36939;&#34892; Python &#30340;&#21704;&#22217;&#19990;&#30028;&#8230;</p>
      <p>
          <a href="https://datainpoint.substack.com/p/week-twenty-python-exercises">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[約維安計畫：Python 技巧]]></title><description><![CDATA[&#31532;&#21313;&#20061;&#36913;&#12290;]]></description><link>https://datainpoint.substack.com/p/week-nineteen-python-tips</link><guid isPermaLink="false">https://datainpoint.substack.com/p/week-nineteen-python-tips</guid><dc:creator><![CDATA[Yao-Jen Kuo]]></dc:creator><pubDate>Mon, 04 Oct 2021 04:29:56 GMT</pubDate><enclosure url="https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/46450cb6-2e10-464b-85d1-83bc682e4208_480x260.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Qx1u!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F34fc2eb9-b445-405a-8c60-693c5b3d975c_480x260.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Qx1u!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F34fc2eb9-b445-405a-8c60-693c5b3d975c_480x260.gif 424w, https://substackcdn.com/image/fetch/$s_!Qx1u!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F34fc2eb9-b445-405a-8c60-693c5b3d975c_480x260.gif 848w, https://substackcdn.com/image/fetch/$s_!Qx1u!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F34fc2eb9-b445-405a-8c60-693c5b3d975c_480x260.gif 1272w, https://substackcdn.com/image/fetch/$s_!Qx1u!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F34fc2eb9-b445-405a-8c60-693c5b3d975c_480x260.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Qx1u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F34fc2eb9-b445-405a-8c60-693c5b3d975c_480x260.gif" width="480" height="260" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/34fc2eb9-b445-405a-8c60-693c5b3d975c_480x260.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:260,&quot;width&quot;:480,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1706317,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Qx1u!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F34fc2eb9-b445-405a-8c60-693c5b3d975c_480x260.gif 424w, https://substackcdn.com/image/fetch/$s_!Qx1u!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F34fc2eb9-b445-405a-8c60-693c5b3d975c_480x260.gif 848w, https://substackcdn.com/image/fetch/$s_!Qx1u!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F34fc2eb9-b445-405a-8c60-693c5b3d975c_480x260.gif 1272w, https://substackcdn.com/image/fetch/$s_!Qx1u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F34fc2eb9-b445-405a-8c60-693c5b3d975c_480x260.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#20358;&#28304;&#65306;giphy.com</figcaption></figure></div><p>&#25105;&#20497;&#24478;<a href="https://datainpoint.substack.com/p/week-thirteen-functions-and-data-types-in-python">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#30340;&#36039;&#26009;&#22411;&#21029;</a>&#19968;&#30452;&#21040;<a href="https://datainpoint.substack.com/p/week-eighteen-modules-in-python">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#30340;&#27169;&#32068;</a>&#20171;&#32057;&#20006;&#19988;&#35342;&#35542;&#20102;&#23416;&#32722;&#20219;&#20309;&#19968;&#20491;&#31243;&#24335;&#35486;&#35328;&#24517;&#35201;&#30340;&#20027;&#38988;&#65306;&#36039;&#26009;&#22411;&#21029;&#12289;&#36039;&#26009;&#32080;&#27083;&#12289;&#27969;&#31243;&#25511;&#21046;&#20197;&#21450;&#31243;&#24335;&#30908;&#32068;&#32340;&#27231;&#21046;&#65292;&#26412;&#31687;&#25991;&#31456;&#26371;&#31777;&#20171;&#24190;&#20491; Python &#20351;&#29992;&#32773;&#24120;&#26371;&#36973;&#36935;&#21040;&#30340;&#25216;&#24039;&#65292;&#36879;&#36942;&#23427;&#20497;&#21487;&#20197;&#25776;&#23531;&#26356;&#31777;&#28500;&#19988;&#26377;&#25928;&#29575;&#30340;&#31243;&#24335;&#30908;&#65292;&#28858;&#23416;&#32722; Python &#22522;&#30990;&#31243;&#24335;&#35373;&#35336;&#33021;&#21147;&#38542;&#27573;&#30059;&#19979;&#23436;&#32654;&#30340;&#21477;&#40670;&#65292;&#36889;&#20123;&#25216;&#24039;&#21253;&#25324;&#65306;Comprehensions&#12289;&#29983;&#25104;&#22120;&#12289;&#20855;&#26377;&#29983;&#25104;&#22120;&#29305;&#24615;&#30340;&#20839;&#24314;&#20989;&#25976;&#20197;&#21450;&#35712;&#21462;&#27284;&#26696;&#12290;</p><h2>Comprehensions</h2><p>Comprehensions &#30446;&#21069;&#36996;&#27794;&#26377;&#19968;&#33268;&#30340;&#20013;&#25991;&#32763;&#35695;&#65292;&#24120;&#35211;&#30340;&#20013;&#25991;&#32763;&#35695;&#26377;&#35299;&#26512;&#24335;&#12289;&#29983;&#25104;&#24335;&#12289;&#24314;&#27083;&#20197;&#21450;&#29702;&#35299;&#65292;&#36889;&#31278;&#24773;&#27841;&#25105;&#27604;&#36611;&#20670;&#21521;&#30452;&#25509;&#20351;&#29992;&#21407;&#26412;&#30340;&#33521;&#25991;&#21517;&#35422;&#65292;Comprehensions &#25351;&#30340;&#26159;&#20381;&#36084;&#24207;&#21015;&#20358;&#24314;&#31435;&#36039;&#26009;&#32080;&#27083;&#30340;&#19968;&#31278;&#35486;&#27861;&#65292;&#22312; Python 2 &#25512;&#20986;&#20102; List comprehension&#65292;&#20134;&#21363;&#36879;&#36942;&#24207;&#21015;&#20358;&#24314;&#31435;&#20018;&#21015;&#65288;list&#65289;&#65292;&#22312; Python 3 &#38500;&#20102;&#21516;&#27171;&#26377; List comprehension &#20043;&#22806;&#65292;&#20063;&#26032;&#22686;&#20102; Dictionary comprehension &#20197;&#21450; Set comprehension&#65292;&#20134;&#21363;&#36879;&#36942;&#24207;&#21015;&#20358;&#24314;&#31435;&#23383;&#20856;&#65288;dict&#65289;&#20197;&#21450;&#38598;&#21512;&#65288;set&#65289;&#12290;</p><p>&#39318;&#20808;&#25105;&#20497;&#22238;&#39015;&#20659;&#32113;&#36879;&#36942;&#24207;&#21015;&#20358;&#24314;&#31435;&#20018;&#21015;&#30340;&#26041;&#24335;&#65292;&#22312;&#36208;&#35370;&#36889;&#20491;&#24207;&#21015;&#20043;&#21069;&#20808;&#24314;&#31435;&#19968;&#20491;&#38263;&#24230;&#28858;&#38646;&#12289;&#31354;&#30340;&#20018;&#21015;&#65292;&#28982;&#24460;&#22312;&#36208;&#35370;&#36942;&#31243;&#20013;&#19968;&#19968;&#23559;&#24819;&#35201;&#23384;&#25918;&#30340;&#20803;&#32032;&#36879;&#36942;&#20018;&#21015;&#30340; <code>append()</code> &#26041;&#27861;&#28155;&#21152;&#12290;</p><pre><code>primes = [2, 3, 5, 7, 11]
squared_primes = []
for p in primes:
    squared_primes.append(p**2)
print(squared_primes)</code></pre><p>&#22914;&#26524;&#26159;&#25505;&#21462; List comprehension &#30340;&#35486;&#27861;&#65292;&#25105;&#20497;&#21487;&#20197;&#36879;&#36942;&#25152;&#35586;&#30340; Python &#19968;&#21015;&#31243;&#24335;&#65288;Python one-liner&#65289;&#23559;&#24314;&#31435;&#20018;&#21015;&#33287;&#36208;&#35370;&#24207;&#21015;&#20841;&#20491;&#27493;&#39519;&#21512;&#32780;&#28858;&#19968;&#12290;</p><pre><code>primes = [2, 3, 5, 7, 11]
squared_primes = [p**2 for p in primes] # list comprehension
print(squared_primes)</code></pre><p>&#20551;&#20351;&#22312;&#36208;&#35370;&#36942;&#31243;&#20013;&#26377;&#26781;&#20214;&#21028;&#26039;&#30340;&#38656;&#27714;&#65292;&#20659;&#32113;&#36879;&#36942;&#24207;&#21015;&#20358;&#24314;&#31435;&#20018;&#21015;&#30340;&#26041;&#24335;&#24517;&#38920;&#22312;&#36852;&#22280;&#30340;&#31243;&#24335;&#21312;&#22602;&#19979;&#20877;&#26032;&#22686;&#19968;&#20491; <code>if</code> &#25944;&#36848;&#30340;&#31243;&#24335;&#21312;&#22602;&#65292;&#22914;&#27492;&#19968;&#20358;&#23601;&#26371;&#26377;&#20841;&#23652;&#30340;&#32302;&#25490;&#12289;&#20841;&#20491;&#31243;&#24335;&#21312;&#22602;&#12290;</p><pre><code>primes = [2, 3, 5, 7, 11]
squared_odd_primes = []
for p in primes:
    if p % 2 == 1:
        squared_odd_primes.append(p**2)
print(squared_odd_primes)</code></pre><p>&#33509;&#26159;&#25505;&#21462; List comprehension &#30340;&#23531;&#27861;&#65292;&#21487;&#20197;&#36914;&#19968;&#27493;&#23559;&#24314;&#31435;&#20018;&#21015;&#12289;&#36208;&#35370;&#24207;&#21015;&#20197;&#21450;&#26781;&#20214;&#21028;&#26039;&#19977;&#20491;&#27493;&#39519;&#21512;&#32780;&#28858;&#19968;&#12290;</p><pre><code>primes = [2, 3, 5, 7, 11]
squared_odd_primes = [p**2 for p in primes if p % 2 == 1] # list comprehension
print(squared_odd_primes)</code></pre><p>&#38500;&#20102;&#33021;&#23481;&#32013; <code>if</code> &#25944;&#36848;&#65292;&#26356;&#21487;&#20197;&#24310;&#20280;&#28858; <code>if-else</code> &#25944;&#36848;&#65292;&#20659;&#32113;&#36879;&#36942;&#24207;&#21015;&#20358;&#24314;&#31435;&#20018;&#21015;&#30340;&#26041;&#24335;&#24517;&#38920;&#22312;&#36852;&#22280;&#30340;&#31243;&#24335;&#21312;&#22602;&#19979;&#20877;&#26032;&#22686;&#19968;&#20491; <code>if-else</code> &#25944;&#36848;&#30340;&#31243;&#24335;&#21312;&#22602;&#65292;&#22914;&#27492;&#19968;&#20358;&#23601;&#26371;&#26377;&#20841;&#23652;&#30340;&#32302;&#25490;&#12289;&#19977;&#20491;&#31243;&#24335;&#21312;&#22602;&#12290;</p><pre><code>primes = [2, 3, 5, 7, 11]
is_even_primes = []
for p in primes:
    if p % 2 == 0:
        is_even_primes.append(True)
    else:
        is_even_primes.append(False)
print(is_even_primes)</code></pre><p>&#33509;&#26159;&#25505;&#21462; List comprehension &#30340;&#23531;&#27861;&#65292;&#21516;&#27171;&#21487;&#20197;&#36914;&#19968;&#27493;&#23559;&#24314;&#31435;&#20018;&#21015;&#12289;&#36208;&#35370;&#24207;&#21015;&#20197;&#21450;&#26781;&#20214;&#21028;&#26039;&#19977;&#20491;&#27493;&#39519;&#21512;&#32780;&#28858;&#19968;&#12290;</p><pre><code>primes = [2, 3, 5, 7, 11]
is_even_primes = [True if p % 2 == 0 else False for p in primes] # list comprehension
print(is_even_primes)</code></pre><p>&#20841;&#30456;&#23565;&#27604;&#20043;&#19979;&#65292;&#20551;&#35373;&#22312;&#36208;&#35370;&#36942;&#31243;&#20013;&#26377; <code>if-else</code> &#25944;&#36848;&#30340;&#35373;&#35336;&#65292;&#25913;&#23531;&#28858; List comprehension &#21487;&#20197;&#23559;&#20845;&#21015;&#31243;&#24335;&#30908;&#22739;&#32302;&#28858;&#19968;&#21015;&#65292;&#31243;&#24335;&#30908;&#31934;&#31777;&#30340;&#25104;&#26524;&#21313;&#20998;&#21487;&#35264;&#12290;</p><p>&#21516;&#27171;&#30340;&#23531;&#27861;&#65292;&#20063;&#21487;&#20197;&#26356;&#25913;&#28858; Set comprehension &#33287; Dict comprehension &#20197;&#19968;&#21015;&#31243;&#24335;&#30908;&#36879;&#36942;&#24207;&#21015;&#24314;&#31435;&#38598;&#21512;&#33287;&#23383;&#20856;&#12290;</p><pre><code>primes = [2, 3, 5, 7, 11]
squared_primes = {p**2 for p in primes} # set comprehension
print(squared_primes)
print(type(squared_primes))
squared_primes = {p: p**2 for p in primes} # dict comprehension
print(squared_primes)
print(type(squared_primes))</code></pre><p>&#21040;&#36889;&#35041;&#65292;&#20013;&#32026;&#32004;&#32173;&#23433;&#21487;&#33021;&#26371;&#29986;&#29983;&#19968;&#20491;&#30097;&#21839;&#65306;&#28858;&#20160;&#40636;&#26377; List&#12289;Set &#33287; Dictionary comprehensions&#65292;&#29544;&#32570;&#20102; Tuple comprehension&#65311;&#26044;&#26159;&#23559; Comprehension &#30340;&#23531;&#27861;&#25913;&#28858;&#20102;&#23567;&#25324;&#34399;&#22039;&#35430;&#30475;&#30475;&#12290;</p><pre><code>primes = [2, 3, 5, 7, 11]
squared_primes = (p**2 for p in primes)
print(squared_primes)
print(type(squared_primes))</code></pre><p>&#27794;&#26377; Tuple comprehension &#30340;&#21407;&#22240;&#26159;&#36889;&#20491;&#23531;&#27861;&#24471;&#21040;&#20102;&#31281;&#28858;&#29983;&#25104;&#22120;&#65288;Generators&#65289;&#30340;&#39006;&#21029;&#65292;&#20063;&#26159;&#26412;&#31687;&#25991;&#31456;&#26371;&#28085;&#33995;&#30340;&#31532;&#20108;&#20491;&#25216;&#24039;&#12290;</p><h2>&#29983;&#25104;&#22120;</h2><p>&#29983;&#25104;&#22120;&#65288;Generators&#65289;&#26159;&#33287; Comprehensions &#30456;&#20284;&#30340;&#35264;&#24565;&#65292;&#37117;&#26159;&#36879;&#36942;&#24207;&#21015;&#20358;&#29983;&#25104;&#36039;&#26009;&#30340;&#27231;&#21046;&#65292;&#19981;&#21516;&#30340;&#22320;&#26041;&#22312;&#26044; Comprehensions &#25152;&#29986;&#20986;&#30340;&#36039;&#26009;&#32080;&#27083;&#20013;&#20786;&#23384;&#30340;&#26159;&#12300;&#36039;&#26009;&#20540;&#12301;&#65292;&#29983;&#25104;&#22120;&#21063;&#26159;&#20786;&#23384;&#12300;&#36039;&#26009;&#20540;&#30340;&#29983;&#25104;&#35215;&#21063;&#12301;&#65292;&#36889;&#27171;&#23376;&#30340;&#12300;&#36039;&#26009;&#20540;&#29983;&#25104;&#35215;&#21063;&#12301;&#24517;&#38920;&#35201;&#32147;&#36942;&#23526;&#20363;&#21270;&#25165;&#33021;&#23559;&#36039;&#26009;&#20540;&#20786;&#23384;&#21040;&#36039;&#26009;&#32080;&#27083;&#20013;&#65292;&#23601;&#22914;&#21516;&#33258;&#34892;&#23450;&#32681;&#22909;&#39006;&#21029;&#20013;&#30340;&#36039;&#26009;&#33287;&#20989;&#25976;&#20043;&#24460;&#65292;&#24517;&#38920;&#36879;&#36942;&#19968;&#20491;&#29289;&#20214;&#20316;&#28858;&#35442;&#39006;&#21029;&#30340;&#23526;&#20363;&#65292;&#25165;&#21487;&#20197;&#20351;&#29992;&#29289;&#20214;&#30340;&#23660;&#24615;&#33287;&#26041;&#27861;&#12290;&#33509;&#26159;&#20197;&#26009;&#29702;&#20358;&#27604;&#21947;&#65292;Comprehensions &#30340;&#36664;&#20986;&#26159;&#26368;&#24460;&#31471;&#19978;&#26700;&#30340;&#33756;&#39194;&#65292;&#32780;&#29983;&#25104;&#22120;&#30340;&#36664;&#20986;&#21063;&#26159;&#33756;&#39194;&#30340;&#39135;&#35676;&#12290;</p><p>&#37027;&#40636;&#35442;&#22914;&#20309;&#12300;&#23526;&#20363;&#21270;&#12301;&#29983;&#25104;&#22120;&#39006;&#21029;&#28858;&#36039;&#26009;&#32080;&#27083;&#30340;&#29289;&#20214;&#21602;&#65311;&#25105;&#20497;&#21487;&#20197;&#25351;&#23450;&#29992; <code>list()</code> &#20989;&#25976;&#25110; <code>tuple()</code> &#20989;&#25976;&#31561;&#23559;&#29983;&#25104;&#22120;&#39006;&#21029;&#21270;&#20316;&#20018;&#21015;&#25110; Tuple&#12290;</p><pre><code>primes = [2, 3, 5, 7, 11]
squared_primes = (p**2 for p in primes)
print(list(squared_primes))  # instantiate as a list
squared_primes = (p**2 for p in primes)
print(tuple(squared_primes)) # instantiate as a tuple</code></pre><p>&#29983;&#25104;&#22120;&#39006;&#21029;&#30456;&#36611;&#26044; Comprehensions &#20855;&#26377;&#20786;&#23384;&#30340;&#25928;&#29575;&#20778;&#21218;&#65292;&#38364;&#26044;&#36889;&#19968;&#40670;&#25110;&#35377;&#24456;&#25277;&#35937;&#65292;&#20294;&#25105;&#20497;&#21487;&#20197;&#24478;&#23427;&#20677;&#33021;&#22816;&#34987;&#23526;&#20363;&#21270;&#19968;&#27425;&#30340;&#29305;&#24615;&#20013;&#35264;&#23519;&#20986;&#36889;&#20491;&#20778;&#21218;&#65292;&#22039;&#35430;&#31532;&#20108;&#27425;&#23526;&#20363;&#21270;&#29983;&#25104;&#22120;&#39006;&#21029;&#23601;&#26371;&#30332;&#29694;&#24471;&#21040;&#19968;&#20491;&#31354;&#30340;&#65288;&#38263;&#24230;&#28858;&#38646;&#65289;&#36039;&#26009;&#32080;&#27083;&#65292;&#34920;&#31034;&#12300;&#36039;&#26009;&#20540;&#29983;&#25104;&#35215;&#21063;&#12301;&#24050;&#32147;&#34987;&#21034;&#38500;&#12290;</p><pre><code>primes = [2, 3, 5, 7, 11]
squared_primes = (p**2 for p in primes)
print(list(squared_primes))  # instantiate as a list
print(tuple(squared_primes)) # empty tuple</code></pre><h2>&#20855;&#26377;&#29983;&#25104;&#22120;&#29305;&#24615;&#30340;&#20839;&#24314;&#20989;&#25976;</h2><p>&#28858;&#20160;&#40636;&#38500;&#20102; Comprehensions &#20197;&#22806;&#25105;&#20497;&#36996;&#35201;&#35469;&#35672;&#29983;&#25104;&#22120;&#36889;&#20491;&#25216;&#24039;&#21602;&#65311;&#22312;&#27794;&#26377;&#31354;&#38291;&#25110;&#32773;&#26178;&#38291;&#30340;&#36039;&#28304;&#38480;&#21046;&#19979;&#65292;&#26159;&#21542;&#26377;&#24517;&#35201;&#22810;&#26296;&#35299;&#36889;&#20491;&#19981;&#26159;&#22826;&#20855;&#39636;&#30340;&#35264;&#24565;&#20358;&#28151;&#28102;&#33258;&#24049;&#21602;&#65311;&#20854;&#23526;&#65292;&#22914;&#26524;&#29983;&#25104;&#22120;&#39006;&#21029;&#20006;&#19981;&#26159;&#37027;&#40636;&#24120;&#35211;&#65292;&#25105;&#33258;&#24049;&#35469;&#28858;&#36889;&#20491;&#25216;&#24039;&#26159;&#21487;&#20197;&#26283;&#26178;&#30053;&#36942;&#30340;&#65292;&#20294;&#26159;&#22240;&#28858;&#26377;&#19981;&#23569;&#26041;&#20415;&#19988;&#22909;&#29992;&#30340;&#20839;&#24314;&#20989;&#25976;&#36664;&#20986;&#20855;&#20633;&#20102;&#29983;&#25104;&#22120;&#39006;&#21029;&#29305;&#24615;&#65292;&#35469;&#35672;&#29983;&#25104;&#22120;&#23601;&#35722;&#24471;&#19981;&#21487;&#25110;&#32570;&#12290;&#20855;&#39636;&#20358;&#35498;&#26377;&#20841;&#39006;&#30340;&#20839;&#24314;&#20989;&#25976;&#65306;&#36845;&#20195;&#22120;&#20989;&#25976;&#65288;Iterator functions&#65289;&#33287;&#20989;&#25976;&#22411;&#20989;&#25976;&#65288;Functional functions&#65289;&#65292;&#20854;&#20013;&#36845;&#20195;&#22120;&#20989;&#25976;&#21253;&#21547; <code>enumerate()</code> &#20989;&#25976;&#20197;&#21450; <code>zip()</code> &#20989;&#25976;&#65292;&#20989;&#25976;&#22411;&#20989;&#25976;&#21253;&#21547; <code>map()</code> &#20989;&#25976;&#33287; <code>filter()</code> &#20989;&#25976;&#12290;</p><p>&#36845;&#20195;&#22120;&#20989;&#25976;&#65306;</p><ul><li><p><code>enumerate()</code> &#20989;&#25976;&#65292;&#33021;&#22816;&#35731;&#36852;&#22280;&#21516;&#26178;&#36208;&#35370;&#24207;&#21015;&#30340;&#12300;&#32034;&#24341;&#20540;&#12301;&#33287;&#12300;&#36039;&#26009;&#20540;&#12301;&#65292;&#22238;&#20659;&#26371;&#26159; <code>enumerate</code> &#39006;&#21029;&#30340;&#23526;&#20363;&#12290;</p></li><li><p><code>zip()</code> &#20989;&#25976;&#65292;&#33021;&#22816;&#35731;&#36852;&#22280;&#21516;&#26178;&#36208;&#35370;&#22810;&#20491;&#24207;&#21015;&#30340;&#12300;&#36039;&#26009;&#20540;&#12301;&#65292;&#22238;&#20659;&#26371;&#26159; <code>zip</code> &#39006;&#21029;&#30340;&#23526;&#20363;&#12290;</p></li></ul><pre><code>primes = [2, 3, 5, 7, 11]
odds = [1, 3, 5, 7, 9]
enum = enumerate(primes)
zipped = zip(primes, odds)
print(enum)
print(list(enum))
print(list(enum))   # empty list
print(zipped)
print(list(zipped))
print(list(zipped)) # empty list</code></pre><p>&#20989;&#25976;&#22411;&#20989;&#25976;&#65306;</p><ul><li><p><code>map()</code> &#20989;&#25976;&#65292;&#36880;&#27425;&#25226;&#24207;&#21015;&#20013;&#30340;&#12300;&#36039;&#26009;&#20540;&#12301;&#30070;&#20316;&#21443;&#25976;&#20659;&#32102;&#36664;&#20837;&#30340;&#20989;&#25976;&#65292;&#22238;&#20659;&#26371;&#26159; <code>map</code> &#39006;&#21029;&#30340;&#23526;&#20363;&#12290;</p></li><li><p><code>filter()</code> &#20989;&#25976;&#65292;&#36880;&#27425;&#25226;&#24207;&#21015;&#20013;&#30340;&#12300;&#36039;&#26009;&#20540;&#12301;&#30070;&#20316;&#21443;&#25976;&#20659;&#32102;&#36664;&#20837;&#30340;&#20989;&#25976;&#65292;&#20445;&#30041;&#20989;&#25976;&#22238;&#20659;&#20540;&#28858;&nbsp;<code>True</code>&nbsp;&#30340;&#36664;&#20986;&#65292;&#22238;&#20659;&#26371;&#26159; <code>filter</code> &#39006;&#21029;&#30340;&#23526;&#20363;&#12290;</p></li></ul><pre><code>def squared(x):
    return x**2
def is_odd(x):
    return x % 2 == 1
primes = [2, 3, 5, 7, 11]
mapped = map(squared, primes)
filtered = filter(is_odd, primes)
print(mapped)
print(list(mapped))
print(list(mapped))   # empty list
print(filtered)
print(list(filtered))
print(list(filtered)) # empty list</code></pre><p>&#21069;&#36848;&#19981;&#35542;&#26159; <code>enumerate</code> &#39006;&#21029;&#30340;&#23526;&#20363;&#12289;<code>zip</code> &#39006;&#21029;&#30340;&#23526;&#20363;&#12289;<code>map</code> &#39006;&#21029;&#30340;&#23526;&#20363;&#25110; <code>filter</code> &#39006;&#21029;&#30340;&#23526;&#20363;&#65292;&#37117;&#26159;&#20855;&#26377;&#29983;&#25104;&#22120;&#29305;&#24615;&#30340;&#39006;&#21029;&#65292;&#24847;&#21363;&#37117;&#38656;&#35201;&#23526;&#20363;&#21270;&#25165;&#33021;&#22816;&#25104;&#28858;&#26377;&#20786;&#23384;&#36039;&#26009;&#20540;&#30340;&#36039;&#26009;&#32080;&#27083;&#12290;</p><p>&#20351;&#29992;&#20989;&#25976;&#22411;&#20989;&#25976;&#30340;&#26178;&#20505;&#65292;&#20551;&#22914;&#20316;&#28858;&#36664;&#20837;&#30340;&#20989;&#25976;&#25805;&#20316;&#26159;&#31777;&#21934;&#30340;&#37007;&#36655;&#65292;&#20363;&#22914;&#21069;&#36848;&#30340; <code>squared()</code> &#20989;&#25976;&#20197;&#21450; <code>is_odd()</code> &#20989;&#25976;&#65292;Python &#20351;&#29992;&#32773;&#26356;&#32722;&#24931;&#26159;&#23559;&#20854;&#23531;&#20316;&#28858; lambda &#20989;&#25976;&#30340;&#32080;&#27083;&#65292;&nbsp;lambda &#20989;&#25976;&#20063;&#31281;&#28858;&#12300;&#21311;&#21517;&#20989;&#25976;&#12301;&#65292;&#19981;&#21516;&#26044;&#20351;&#29992;&nbsp;<code>def</code>&nbsp;&#35486;&#27861;&#23450;&#32681;&#20989;&#25976;&#65292;&#21487;&#20197;&#22312;&#25645;&#37197;&#20989;&#25976;&#22411;&#20989;&#25976;&#30340;&#24773;&#27841;&#19979;&#12300;&#21516;&#26178;&#12301;&#23450;&#32681;&#33287;&#20351;&#29992;&#12290;</p><pre><code>primes = [2, 3, 5, 7, 11]
print(list(map(lambda x: x**2, primes)))
print(list(filter(lambda x: x % 2 == 1, primes)))</code></pre><h2>&#35712;&#21462;&#27284;&#26696;</h2><p>&#38754;&#23565;&#21103;&#27284;&#21517;&#28858; txt&#12289;csv &#25110;&#32773; json &#30340;&#32020;&#25991;&#23383;&#27284;&#26696;&#65292;&#36879;&#36942; Python &#30340; <code>with</code> &#35486;&#27861;&#65292;&#31243;&#24335;&#26371;&#33258;&#21205;&#36914;&#34892;&#27284;&#26696;&#30456;&#38364;&#36039;&#28304;&#30340;&#24314;&#31435;&#12289;&#28165;&#29702;&#33287;&#22238;&#25910;&#65292;&#22312; <code>with</code> &#35486;&#27861;&#26550;&#27083;&#19979;&#20351;&#29992;&#20839;&#24314;&#20989;&#25976; <code>open(file_path, &#8220;r&#8220;)</code> &#24314;&#31435;&#27284;&#26696;&#29289;&#20214;&#65292;&#23601;&#21487;&#20197;&#35731;&#20351;&#29992;&#32773;&#36629;&#39686;&#22320;&#22312;&#26377;&#36039;&#28304;&#31649;&#29702;&#30340;&#21069;&#25552;&#19979;&#36914;&#34892;&#27284;&#26696;&#30340;&#35712;&#21462;&#65292;&#32780;&#19981;&#26371;&#26377;&#27284;&#26696;&#34987;&#37782;&#23450;&#25110;&#32773;&#37679;&#35492;&#30340;&#24773;&#27841;&#12290;</p><p>&#21103;&#27284;&#21517;&#28858; txt &#30340;&#32020;&#25991;&#23383;&#27284;&#26696;&#65292;&#21487;&#20197;&#29992;&#27284;&#26696;&#29289;&#20214;&#30340; <code>readlines()</code> &#26041;&#27861;&#23559;&#27284;&#26696;&#20839;&#23481;&#19968;&#21015;&#19968;&#21015;&#65288;row-by-row&#65289;&#35712;&#20837;&#25104;&#28858;&#20018;&#21015;&#20013;&#30340;&#20803;&#32032;&#12290;</p><pre><code>with open("the_shawshank_redemption_summaries.txt", "r") as file:
    the_shawshank_redemption_summaries = file.readlines()
for e in the_shawshank_redemption_summaries:
    print(e)</code></pre><p>&#21103;&#27284;&#21517;&#28858; csv &#30340;&#32020;&#25991;&#23383;&#27284;&#26696;&#65292;&#21487;&#20197;&#29992;&#27161;&#28310;&#27169;&#32068; <code>csv</code> &#30340; <code>DictReader</code> &#39006;&#21029;&#23559; csv &#27284;&#26696;&#30340;&#27599;&#19968;&#21015;&#35712;&#20837;&#25104;&#28858;&#19968;&#20491;&#20197;&#27396;&#20301;&#21517;&#31281;&#20316;&#28858;&#37749;&#65288;Keys&#65289;&#12289;&#35264;&#28204;&#20540;&#20839;&#23481;&#20316;&#28858;&#20540;&#65288;Values&#65289;&#30340;&#23383;&#20856;&#12290;</p><pre><code>import csv

with open("imdb_top_rated_movies.csv", "r") as file:
    csv_dict_reader = csv.DictReader(file)
    for row in csv_dict_reader:
        print(row)</code></pre><p>&#21103;&#27284;&#21517;&#28858; json &#30340;&#32020;&#25991;&#23383;&#27284;&#26696;&#65292;&#21487;&#20197;&#29992;&#27161;&#28310;&#27169;&#32068; <code>json</code> &#30340; <code>load()</code> &#20989;&#25976;&#23559; json &#27284;&#26696;&#35712;&#20837;&#25104;&#28858;&#19968;&#20491;&#23383;&#20856;&#25110;&#32773;&#30001;&#23383;&#20856;&#25152;&#32068;&#21512;&#32780;&#25104;&#30340;&#20018;&#21015;&#12290;</p><pre><code>import json

with open("imdb_top_rated_movies.json", "r") as file:
    list_of_dicts = json.load(file)
for row in list_of_dicts:
    print(row)</code></pre><p>&#22312;&#35469;&#35672;&#20102; Comprehensions&#12289;&#29983;&#25104;&#22120;&#12289;&#20855;&#26377;&#29983;&#25104;&#22120;&#29305;&#24615;&#30340;&#20839;&#24314;&#20989;&#25976;&#20197;&#21450;&#35712;&#21462;&#27284;&#26696;&#31561;&#25216;&#24039;&#20043;&#24460;&#65292;&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;&#31532;&#21313;&#20061;&#36913;&#20358;&#21040;&#23614;&#32882;&#65292;&#24076;&#26395;&#24744;&#20063;&#21644;&#25105;&#19968;&#27171;&#26399;&#24453;&#19979;&#19968;&#31687;&#25991;&#31456;&#12290;</p><h2>&#24310;&#20280;&#38321;&#35712;</h2><ul><li><p><a href="https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions">https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions</a></p></li><li><p><a href="https://docs.python.org/3/library/csv.html">https://docs.python.org/3/library/csv.html</a></p></li><li><p><a href="https://docs.python.org/3/library/json.html">https://docs.python.org/3/library/json.html</a></p></li></ul><div><hr></div><p>&#23565;&#26044;&#36889;&#31687;&#25991;&#31456;&#26377;&#20160;&#40636;&#24819;&#27861;&#21602;&#65311;&#21916;&#27489;&#128571;&#12289;&#30041;&#35328;&#128587;&#8205;&#9794;&#65039;&#25110;&#32773;&#20998;&#20139;&#128588;</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://datainpoint.substack.com/p/week-nineteen-python-tips/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://datainpoint.substack.com/p/week-nineteen-python-tips/comments"><span>Leave a comment</span></a></p><h2>&#35336;&#30059;&#23416;&#21729;&#23560;&#21312;</h2><p>&#20184;&#36027;&#35330;&#38321;&#38651;&#23376;&#22577;&#30340;&#26371;&#21729;&#21487;&#20197;&#40670;&#36984; nbgitpuller &#36899;&#32080;&#23559;&#26412;&#31687;&#25991;&#31456;&#23436;&#25972;&#30340; Jupyter Notebook &#20197;&#21450;&#31684;&#20363;&#36039;&#26009;&#65288;the_shawshank_redemption_summaries.txt&#12289;imdb_top_rated_movies.csv&#12289;imdb_top_rated_movies.json&#65289;&#35079;&#35069;&#21040;&#33258;&#24049;&#30340; Jupyter Server&#65306;</p><p><a href="https://lab.datainpoint.com/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fdatainpoint%2Fweek-nineteen-python-tips&amp;urlpath=tree%2Fweek-nineteen-python-tips%2F&amp;branch=main">nbgitpuller &#36899;&#32080;</a></p><p>&#20282;&#26381;&#22120;&#36984;&#38917;&#36984;&#25799;&#38928;&#35373;&#30340;&#12300;Data science environment&#65306;&#23416;&#32722; Python&#12289;R &#33287; Julia &#30340;&#36039;&#26009;&#31185;&#23416;&#29872;&#22659;&#12301;&#23601;&#21487;&#20197;&#38918;&#21033;&#36939;&#20316;&#25991;&#31456;&#20013;&#30340;&#31684;&#20363;&#31243;&#24335;&#12290;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HMwv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HMwv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 424w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 848w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1272w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!HMwv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png" width="1456" height="964" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:964,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:137396,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!HMwv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 424w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 848w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1272w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#36984;&#25799;&#12300;Data science environment&#65306;&#23416;&#32722; Python&#12289;R &#33287; Julia &#30340;&#36039;&#26009;&#31185;&#23416;&#29872;&#22659;&#12301;</figcaption></figure></div>]]></content:encoded></item><item><title><![CDATA[約維安計畫：Python 的模組]]></title><description><![CDATA[&#31532;&#21313;&#20843;&#36913;&#12290;]]></description><link>https://datainpoint.substack.com/p/week-eighteen-modules-in-python</link><guid isPermaLink="false">https://datainpoint.substack.com/p/week-eighteen-modules-in-python</guid><dc:creator><![CDATA[Yao-Jen Kuo]]></dc:creator><pubDate>Tue, 14 Sep 2021 14:18:26 GMT</pubDate><enclosure url="https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/c68d5f53-5194-43b4-9744-e066bd06b812_500x268.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!xNG4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fda2510fb-451d-4283-8fff-45fc6caa7762_500x268.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!xNG4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fda2510fb-451d-4283-8fff-45fc6caa7762_500x268.gif 424w, https://substackcdn.com/image/fetch/$s_!xNG4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fda2510fb-451d-4283-8fff-45fc6caa7762_500x268.gif 848w, https://substackcdn.com/image/fetch/$s_!xNG4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fda2510fb-451d-4283-8fff-45fc6caa7762_500x268.gif 1272w, https://substackcdn.com/image/fetch/$s_!xNG4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fda2510fb-451d-4283-8fff-45fc6caa7762_500x268.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!xNG4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fda2510fb-451d-4283-8fff-45fc6caa7762_500x268.gif" width="500" height="268" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/da2510fb-451d-4283-8fff-45fc6caa7762_500x268.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:268,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1810615,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!xNG4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fda2510fb-451d-4283-8fff-45fc6caa7762_500x268.gif 424w, https://substackcdn.com/image/fetch/$s_!xNG4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fda2510fb-451d-4283-8fff-45fc6caa7762_500x268.gif 848w, https://substackcdn.com/image/fetch/$s_!xNG4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fda2510fb-451d-4283-8fff-45fc6caa7762_500x268.gif 1272w, https://substackcdn.com/image/fetch/$s_!xNG4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fda2510fb-451d-4283-8fff-45fc6caa7762_500x268.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#20358;&#28304;&#65306;giphy.com</figcaption></figure></div><p><a href="https://datainpoint.substack.com/p/week-seventeen-classes-in-python">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#30340;&#39006;&#21029;</a>&#35498;&#26126;&#31243;&#24335;&#35373;&#35336;&#24107;&#22240;&#25033;&#19981;&#21516;&#30446;&#30340;&#20197;&#21450;&#25033;&#29992;&#22580;&#26223;&#65292;&#26377;&#32068;&#32340;&#31243;&#24335;&#30908;&#30340;&#38656;&#27714;&#65292;&#24076;&#26395;&#21487;&#20197;&#31777;&#28500;&#19988;&#26377;&#25928;&#29575;&#22320;&#23436;&#25104;&#20219;&#21209;&#65292;Python &#33287;&#22823;&#22810;&#25976;&#30340;&#31243;&#24335;&#35486;&#35328;&#30456;&#21516;&#65292;&#25793;&#26377;&#20854;&#20182;&#32068;&#32340;&#31243;&#24335;&#30908;&#30340;&#27231;&#21046;&#65292;&#20855;&#39636;&#32780;&#35328;&#26377;&#19977;&#20491;&#23652;&#27425;&#65292;&#30001;&#23567;&#32780;&#22823;&#20381;&#24207;&#28858;&#65306;</p><ol><li><p>&#20989;&#25976;&#65288;Functions&#65289;&#12290;</p></li><li><p>&#39006;&#21029;&#65288;Classes&#65289;&#12290;</p></li><li><p>&#27169;&#32068;&#65288;Modules&#65289;&#12290;</p></li></ol><p>&#26412;&#31687;&#25991;&#31456;&#35201;&#20171;&#32057;&#32068;&#32340;&#31243;&#24335;&#30908;&#27231;&#21046;&#30340;&#31532;&#19977;&#20491;&#23652;&#27425;&#65306;<strong>&#27169;&#32068;</strong>&#12290;</p><h2>&#20160;&#40636;&#26159;&#27169;&#32068;</h2><p>&#27169;&#32068;&#26159; Python &#32068;&#32340;&#31243;&#24335;&#30908;&#21253;&#23481;&#24615;&#26368;&#39640;&#30340;&#27231;&#21046;&#65292;&#30070;&#25105;&#20497;&#33258;&#34892;&#23450;&#32681;&#20102;&#28858;&#25976;&#30526;&#22810;&#30340;&#20989;&#25976;&#33287;&#39006;&#21029;&#65292;&#19979;&#19968;&#27493;&#23601;&#21487;&#20197;&#20351;&#29992;&#27169;&#32068;&#20358;&#21253;&#35037;&#36889;&#20123;&#31243;&#24335;&#30908;&#65292;&#37027;&#40636;&#27169;&#32068;&#31350;&#31455;&#22312;&#23526;&#39636;&#19978;&#30340;&#24418;&#24335;&#28858;&#20309;&#65311;&#20855;&#39636;&#20358;&#35498;&#65292;&#27169;&#32068;&#23601;&#26159;&#21103;&#27284;&#21517;&#28858; .py &#30340;&#27284;&#26696;&#65288;Files&#65289;&#25110;&#36039;&#26009;&#22846;&#65288;Folders&#65289;&#65292;&#22312;&#35041;&#38957;&#35352;&#37636;&#20102;&#33258;&#34892;&#23450;&#32681;&#30340;&#20989;&#25976;&#20197;&#21450;&#39006;&#21029;&#12290;&#19968;&#20491;&#21517;&#28858; my_module.py &#30340;&#27284;&#26696;&#65292;&#23601;&#34987;&#31281;&#28858;&#12300;my_module&#12301;&#27169;&#32068;&#65292;&#30070;&#27284;&#26696;&#30340;&#25976;&#37327;&#20063;&#22686;&#22810;&#20102;&#30340;&#26178;&#20505;&#65292;&#23601;&#21487;&#20197;&#21033;&#29992;&#36039;&#26009;&#22846;&#25910;&#32013;&#36889;&#20123;&#27284;&#26696;&#65292;&#32780;&#19968;&#20491;&#21517;&#28858; my_module &#30340;&#36039;&#26009;&#22846;&#65292;&#20063;&#21516;&#27171;&#34987;&#31281;&#28858;&#12300;my_module&#12301;&#27169;&#32068;&#12290;</p><p>&#22914;&#21516;&#20989;&#25976;&#26377;&#19981;&#21516;&#20358;&#28304;&#19968;&#33324;&#65292;&#27169;&#32068;&#21516;&#27171;&#20063;&#26377;&#19977;&#20491;&#20358;&#28304;&#65306;</p><ol><li><p>&#27161;&#28310;&#27169;&#32068;&#12290;</p></li><li><p>&#31532;&#19977;&#26041;&#27169;&#32068;&#12290;</p></li><li><p>&#20358;&#33258;&#20351;&#29992;&#32773;&#30340;&#23450;&#32681;&#12290;</p></li></ol><p>Python &#31243;&#24335;&#35486;&#35328;&#24341;&#20197;&#28858;&#20658;&#30340;&#19968;&#20491;&#29305;&#40670;&#26159;&#33258;&#24118;&#38651;&#27744;&#21746;&#23416;&#65288;Battery included philosophy&#65289;&#65292;&#36889;&#20491;&#24418;&#23481;&#25351;&#30340;&#26159;&#26997;&#28858;&#35920;&#23500;&#30340;&#27161;&#28310;&#27169;&#32068;&#65292;&#36889;&#20491;&#29305;&#40670;&#24478;&#27161;&#28310;&#27169;&#32068;&#30340;&#23448;&#26041;&#25991;&#20214;&#36899;&#32080;&#21487;&#35211;&#19968;&#26001;&#65306;<a href="https://docs.python.org/3/library">https://docs.python.org/3/library</a>&#12290;</p><h2>&#20351;&#29992;&#27169;&#32068;</h2><p>&#22914;&#26524;&#24819;&#35201;&#20351;&#29992;&#27161;&#28310;&#27169;&#32068;&#20013;&#30340;&#21151;&#33021;&#65292;&#35201;&#36879;&#36942; <code>import</code> &#30340;&#25351;&#20196;&#23450;&#32681;&#65292;&#20877;&#36879;&#36942;&#21477;&#34399;&#65288;.&#65289;&#21443;&#29031;&#38468;&#23660;&#20854;&#20013;&#30340;&#20989;&#25976;&#25110;&#32773;&#39006;&#21029;&#12290;</p><pre><code>import module_name

module_name.function_name()       # use module's function
object = module_name.class_name() # use module's class</code></pre><p>&#20363;&#22914;&#36617;&#20837;&#27161;&#28310;&#27169;&#32068; <code>random</code>&#65292;&#28982;&#24460;&#20351;&#29992;&#38468;&#23660;&#26044;&#20854;&#20013;&#30340; <code>randint()</code> &#20989;&#25976;&#12290;</p><pre><code>import random

random.randint(0, 1)</code></pre><p>&#20351;&#29992;&#27169;&#32068;&#30340;&#20351;&#29992;&#32773;&#20006;&#19981;&#26371;&#30693;&#36947;&#20855;&#39636;&#30340;&#24418;&#24335;&#26159;&#21103;&#27284;&#21517;&#28858; .py &#30340;&#27284;&#26696;&#25110;&#36039;&#26009;&#22846;&#65292;&#22914;&#26524;&#24819;&#35201;&#26296;&#35299;&#27169;&#32068;&#24418;&#24335;&#20197;&#21450;&#20786;&#23384;&#22312;&#38651;&#33126;&#20013;&#30340;&#36335;&#24465;&#65292;&#21487;&#20197;&#27298;&#35222;&#27169;&#32068;&#30340; <code>__file__</code> &#23660;&#24615;&#12290;</p><pre><code>print(random.__file__)</code></pre><p>&#20551;&#22914;&#26377;&#26178;&#20505;&#25105;&#20497;&#21482;&#38656;&#35201;&#21462;&#29992;&#27169;&#32068;&#20013;&#23569;&#37096;&#20998;&#30340;&#20989;&#25976;&#25110;&#39006;&#21029;&#65292;&#20063;&#21487;&#20197;&#12300;&#36984;&#25799;&#24615;&#12301;&#22320;&#36879;&#36942; <code>from</code> &#25645;&#37197; <code>import</code> &#20358;&#36617;&#20837;&#25351;&#23450;&#21151;&#33021;&#12290;</p><pre><code>from module_name import function_name
from module_name import class_name

function_name()       # use module's function
object = class_name() # use module's class</code></pre><p>&#20363;&#22914;&#25351;&#23450;&#36617;&#20837;&#27161;&#28310;&#27169;&#32068; <code>random</code> &#20013;&#30340; <code>randint()</code> &#20989;&#25976;&#12290;</p><pre><code>from random import randint

randint(0, 1)</code></pre><p>&#38500;&#20102;&#21487;&#20197;&#20381;&#29031;&#20351;&#29992;&#32773;&#30340;&#38656;&#27714;&#22810;&#23521;&#27770;&#23450;&#35201;&#36617;&#20837;&#25972;&#20491;&#27169;&#32068;&#25110;&#20677;&#36617;&#20837;&#37096;&#20998;&#21151;&#33021;&#65292;&#21478;&#22806;&#19968;&#20491;&#26356;&#22909;&#30340;&#21028;&#26039;&#28310;&#21063;&#23601;&#26159;&#20223;&#25928;&#27169;&#32068;&#30340;&#35498;&#26126;&#25991;&#20214;&#65288;Documentation&#65289;&#30340;&#20570;&#27861;&#12290;</p><h2>&#20351;&#29992;&#31532;&#19977;&#26041;&#27169;&#32068;</h2><p>&#31532;&#19977;&#26041;&#27169;&#32068;&#20006;&#19981;&#20687;&#27161;&#28310;&#27169;&#32068;&#26371;&#22312;&#23433;&#35037; Python &#30340;&#26178;&#20505;&#23601;&#19968;&#20341;&#23433;&#35037;&#65292;&#21363;&#20415;&#26159;&#36039;&#26009;&#31185;&#23416;&#26222;&#36941;&#20351;&#29992;&#30340; Anaconda &#38928;&#20808;&#23433;&#35037;&#20102;&#36229;&#36942; 7,500 &#20491;&#27169;&#32068;&#65292;&#20063;&#24456;&#26377;&#21487;&#33021;&#29544;&#28431;&#20102;&#24819;&#35201;&#20351;&#29992;&#30340;&#29305;&#23450;&#27169;&#32068;&#65292;&#22240;&#27492;&#36617;&#20837;&#20043;&#21069;&#24517;&#38920;&#35201;&#20808;&#30906;&#35469;&#27169;&#32068;&#26159;&#21542;&#24050;&#32147;&#23433;&#35037;&#22949;&#30070;&#65292;&#22914;&#26524;&#27169;&#32068;&#27794;&#26377;&#23433;&#35037;&#23601;&#22039;&#35430;&#36617;&#20837;&#65292;&#26371;&#36973;&#36935;&#21040; <code>ModuleNotFoundError</code>&#12290;</p><pre><code>try:
    import third_party_module
except ModuleNotFoundError:
    print("Module is not installed.")</code></pre><p>&#23433;&#35037;&#27169;&#32068;&#30340;&#26041;&#24335;&#26159;&#22312;&#21629;&#20196;&#21015;&#20197;&nbsp;<code>pip install</code> &#23433;&#35037;&#65292;&#22914;&#26524;&#35201;&#26356;&#26032;&#24050;&#23433;&#35037;&#30340;&#27169;&#32068;&#65292;&#21482;&#35201;&#21152;&#19978;&#21443;&#25976; -U &#21363;&#21487;&#12290;pip&nbsp;&#26159; Python &#30340;&#27169;&#32068;&#31649;&#29702;&#31995;&#32113;&#65292;&#21487;&#20197;&#29992;&#20358;&#24478;&nbsp;<a href="https://pypi.org/">PyPI&#65288;Python Package Index&#65289;</a>&#19979;&#36617;&#12289;&#23433;&#35037;&#21644;&#31649;&#29702;&#27169;&#32068;&#65292;&#24478; Python 3.4 &#36215;&#37117;&#26371;&#38928;&#20808;&#23433;&#35037;&nbsp;pip&#12290;</p><pre><code>~$ pip install module_name
~$ pip install -U module_name</code></pre><p>&#24536;&#35352;&#20102;&#20160;&#40636;&#26159;&#21629;&#20196;&#21015;&#21966;&#65311;&#35079;&#32722;&#19968;&#19979;<a href="https://datainpoint.substack.com/p/week-two-a-taste-of-command-line">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;&#21021;&#22039;&#21629;&#20196;&#21015;</a>&#30340;&#28363;&#21619;&#21543;&#65281;</p><p>&#20363;&#22914;&#23433;&#35037;&#25976;&#20540;&#35336;&#31639;&#30340;&#31532;&#19977;&#26041;&#27169;&#32068; <code>numpy</code>&#12290;</p><pre><code>~$ pip install numpy
~$ pip install -U numpy</code></pre><p>&#26377;&#30340;&#26178;&#20505;&#22240;&#28858;&#27169;&#32068;&#30340;&#21517;&#31281;&#27604;&#36611;&#38263;&#65292;&#21487;&#20197;&#29992; <code>as</code> &#20445;&#30041;&#23383;&#21629;&#21517;&#32302;&#23531;&#26041;&#20415;&#20351;&#29992;&#65292;&#27169;&#32068;&#21629;&#21517;&#32302;&#23531;&#38614;&#28982;&#21487;&#20197;&#20381;&#20491;&#20154;&#20559;&#22909;&#21462;&#21517;&#65292;&#20294;&#26159;&#24314;&#35696;&#36981;&#23432;&#35498;&#26126;&#25991;&#20214;&#20013;&#30340;&#32302;&#23531;&#65292;&#20687;&#26159;&#25976;&#20540;&#35336;&#31639;&#30340;&#31532;&#19977;&#26041;&#27169;&#32068; <code>numpy</code> &#22312;&#23448;&#26041;&#25991;&#20214;&#20013;&#32302;&#23531;&#28858; <code>np</code>&#65292;&#25152;&#26377;&#20154;&#37117;&#26371;&#20351;&#29992;&#36889;&#20491;&#32302;&#23531;&#12290;</p><pre><code>import numpy as np

np.random.randint(0, 2, size=5)</code></pre><h2>&#33258;&#34892;&#23450;&#32681;&#27169;&#32068;</h2><p>&#23559;&#20989;&#25976;&#12289;&#39006;&#21029;&#25776;&#23531;&#22312;&#24037;&#20316;&#30446;&#37636;&#65288;Working directory&#65289;&#20013;&#19968;&#20491;&#21103;&#27284;&#21517;&#28858; .py &#30340;&#27284;&#26696;&#20013;&#65292;&#33509;&#26159;&#20989;&#25976;&#33287;&#39006;&#21029;&#30340;&#25976;&#37327;&#30526;&#22810;&#26178;&#65292;&#23601;&#21487;&#20197;&#29992;&#19968;&#20491;&#36039;&#26009;&#22846;&#23559;&#36889;&#20123;&#27284;&#26696;&#25910;&#32013;&#36215;&#20358;&#65292;&#19981;&#35542;&#26159;&#36039;&#26009;&#22846;&#21517;&#31281;&#25110;&#27284;&#26696;&#21517;&#31281;&#65292;&#37117;&#26159;&#27169;&#32068;&#30340;&#21629;&#21517;&#65292;&#33509;&#24819;&#35201;&#21462;&#24471;&#20854;&#20013;&#30340;&#20989;&#25976;&#33287;&#39006;&#21029;&#65292;&#23601;&#35201;&#36617;&#20837;&#27169;&#32068;&#20043;&#24460;&#20381;&#29031;&#36039;&#26009;&#22846;&#12289;&#27284;&#26696;&#12289;&#39006;&#21029;&#33287;&#20989;&#25976;&#30340;&#21517;&#31281;&#29992;&#21477;&#34399;&#65288;.&#65289;&#21443;&#29031;&#21462;&#29992;&#12290;</p><p>&#20363;&#22914;&#22312;&#24037;&#20316;&#30446;&#37636;&#20013;&#26032;&#22686;&#25793;&#26377;&#19979;&#36848;&#27193;&#29376;&#32080;&#27083;&#30340;&#36039;&#26009;&#22846;&#65306;</p><pre><code>my_modules
- calculator.py
- stats.py</code></pre><p>&#22312; calculator.py &#20013;&#23531;&#20837;<a href="https://datainpoint.substack.com/p/week-seventeen-classes-in-python">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#30340;&#39006;&#21029;</a>&#20013;&#25152;&#33258;&#34892;&#23450;&#32681;&#30340; <code>SimpleCalculator</code> &#39006;&#21029;&#12290;</p><pre><code># calculator.py
class SimpleCalculator:
    def __init__(self, a, b):
        self.a = a
        self.b = b
    def __repr__(self):
        return "a: {}, b: {}".format(self.a, self.b)
    def add(self):
        return self.a + self.b</code></pre><p>&#22312; stats.py &#20013;&#23531;&#20837;&#33258;&#34892;&#23450;&#32681;&#30340; <code>mean</code> &#20989;&#25976;&#12290;</p><pre><code># stats.py
def mean(*args):
    return sum(args) / len(args)</code></pre><p>&#20197; <code>import</code> &#25351;&#20196;&#36617;&#20837;&#27169;&#32068;&#20043;&#24460;&#20381;&#29031;&#36039;&#26009;&#22846;&#12289;&#27284;&#26696;&#12289;&#39006;&#21029;&#33287;&#20989;&#25976;&#30340;&#21517;&#31281;&#29992;&#21477;&#34399;&#65288;.&#65289;&#21443;&#29031;&#21462;&#29992;&#12290;</p><pre><code>import my_modules.calculator
import my_modules.stats

sc = my_modules.calculator.SimpleCalculator(5, 6)
print(sc.add())
print(my_modules.stats.mean(5, 6, 55, 66, 5566))</code></pre><p>&#30070;&#28982;&#20063;&#33021;&#22816;&#25645;&#37197; <code>from</code> &#36617;&#20837; <code>my_modules</code> &#27169;&#32068;&#19979;&#30340; <code>calculator</code> &#27169;&#32068;&#33287; <code>stats</code> &#27169;&#32068;&#24460;&#20877;&#21462;&#29992;&#20854;&#20013;&#30340;&#39006;&#21029;&#33287;&#20989;&#25976;&#12290;</p><pre><code>from my_modules import calculator
from my_modules import stats

sc = calculator.SimpleCalculator(5, 6)
print(sc.add())
print(stats.mean(5, 6, 55, 66, 5566))</code></pre><p>&#22914;&#27492;&#19968;&#20358;&#65292;&#25105;&#20497;&#23601;&#33021;&#22816;&#26296;&#35299;&#26410;&#20358;&#22312;&#36039;&#26009;&#20998;&#26512;&#38542;&#27573;&#25152;&#20351;&#29992;&#30340;&#31532;&#19977;&#26041;&#27169;&#32068;&#65292;&#20854;&#20855;&#39636;&#30340;&#24418;&#24335;&#28858;&#20309;&#36914;&#32780;&#21487;&#20197;&#26356;&#29087;&#32244;&#22320;&#20351;&#29992;&#20102;&#12290;&#22312;&#35469;&#35672;&#20102;&#27169;&#32068;&#20043;&#24460;&#65292;&#31532;&#21313;&#20843;&#36913;&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#30340;&#27169;&#32068;&#20358;&#21040;&#23614;&#32882;&#65292;&#24076;&#26395;&#24744;&#20063;&#21644;&#25105;&#19968;&#27171;&#26399;&#24453;&#19979;&#19968;&#31687;&#25991;&#31456;&#12290;</p><h2>&#24310;&#20280;&#38321;&#35712;</h2><ul><li><p><a href="https://docs.python.org/3/library">https://docs.python.org/3/library</a></p></li><li><p><a href="https://docs.python.org/3/installing/index.html">https://docs.python.org/3/installing/index.html</a></p></li><li><p><a href="https://pip.pypa.io/en/stable">https://pip.pypa.io/en/stable</a></p></li><li><p><a href="https://pypi.org">https://pypi.org</a></p></li></ul><div><hr></div><p>&#23565;&#26044;&#36889;&#31687;&#25991;&#31456;&#26377;&#20160;&#40636;&#24819;&#27861;&#21602;&#65311;&#21916;&#27489;&#128571;&#12289;&#30041;&#35328;&#128587;&#8205;&#9794;&#65039;&#25110;&#32773;&#20998;&#20139;&#128588;</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://datainpoint.substack.com/p/week-eighteen-modules-in-python/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://datainpoint.substack.com/p/week-eighteen-modules-in-python/comments"><span>Leave a comment</span></a></p><h2>&#35336;&#30059;&#23416;&#21729;&#23560;&#21312;</h2><p>&#20184;&#36027;&#35330;&#38321;&#38651;&#23376;&#22577;&#30340;&#26371;&#21729;&#21487;&#20197;&#40670;&#36984; nbgitpuller &#36899;&#32080;&#23559;&#26412;&#31687;&#25991;&#31456;&#23436;&#25972;&#30340; Jupyter Notebook &#20197;&#21450;&#31684;&#20363;&#27169;&#32068;&#35079;&#35069;&#21040;&#33258;&#24049;&#30340; Jupyter Server&#65306;</p><p><a href="https://lab.datainpoint.com/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fdatainpoint%2Fweek-eighteen-modules-in-python&amp;urlpath=tree%2Fweek-eighteen-modules-in-python%2F&amp;branch=main">nbgitpuller &#36899;&#32080;</a></p><p>&#20282;&#26381;&#22120;&#36984;&#38917;&#36984;&#25799;&#38928;&#35373;&#30340;&#12300;Data science environment&#65306;&#23416;&#32722; Python&#12289;R &#33287; Julia &#30340;&#36039;&#26009;&#31185;&#23416;&#29872;&#22659;&#12301;&#23601;&#21487;&#20197;&#38918;&#21033;&#36939;&#20316;&#25991;&#31456;&#20013;&#30340;&#31684;&#20363;&#31243;&#24335;&#12290;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HMwv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HMwv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 424w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 848w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1272w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!HMwv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png" width="1456" height="964" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:964,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:137396,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!HMwv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 424w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 848w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1272w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#36984;&#25799;&#12300;Data science environment&#65306;&#23416;&#32722; Python&#12289;R &#33287; Julia &#30340;&#36039;&#26009;&#31185;&#23416;&#29872;&#22659;&#12301;</figcaption></figure></div>]]></content:encoded></item><item><title><![CDATA[約維安計畫：Python 的類別]]></title><description><![CDATA[&#31532;&#21313;&#19971;&#36913;&#12290;]]></description><link>https://datainpoint.substack.com/p/week-seventeen-classes-in-python</link><guid isPermaLink="false">https://datainpoint.substack.com/p/week-seventeen-classes-in-python</guid><dc:creator><![CDATA[Yao-Jen Kuo]]></dc:creator><pubDate>Thu, 09 Sep 2021 14:24:11 GMT</pubDate><enclosure url="https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/e70a6e07-7d94-436e-9961-b0166ca67c87_400x225.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1BBv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F9cb002a9-ca62-46ba-8974-2e3e748cbd7c_400x225.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1BBv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F9cb002a9-ca62-46ba-8974-2e3e748cbd7c_400x225.gif 424w, https://substackcdn.com/image/fetch/$s_!1BBv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F9cb002a9-ca62-46ba-8974-2e3e748cbd7c_400x225.gif 848w, https://substackcdn.com/image/fetch/$s_!1BBv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F9cb002a9-ca62-46ba-8974-2e3e748cbd7c_400x225.gif 1272w, https://substackcdn.com/image/fetch/$s_!1BBv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F9cb002a9-ca62-46ba-8974-2e3e748cbd7c_400x225.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1BBv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F9cb002a9-ca62-46ba-8974-2e3e748cbd7c_400x225.gif" width="400" height="225" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/9cb002a9-ca62-46ba-8974-2e3e748cbd7c_400x225.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:225,&quot;width&quot;:400,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:581505,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!1BBv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F9cb002a9-ca62-46ba-8974-2e3e748cbd7c_400x225.gif 424w, https://substackcdn.com/image/fetch/$s_!1BBv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F9cb002a9-ca62-46ba-8974-2e3e748cbd7c_400x225.gif 848w, https://substackcdn.com/image/fetch/$s_!1BBv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F9cb002a9-ca62-46ba-8974-2e3e748cbd7c_400x225.gif 1272w, https://substackcdn.com/image/fetch/$s_!1BBv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F9cb002a9-ca62-46ba-8974-2e3e748cbd7c_400x225.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a><figcaption class="image-caption">&#20358;&#28304;&#65306;giphy.com</figcaption></figure></div><p>&#25105;&#20497;&#22312;<a href="https://datainpoint.substack.com/p/week-sixteen-functions-in-python">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#30340;&#20989;&#25976;</a>&#35469;&#35672;&#20102;&#20989;&#25976;&#30340;&#35264;&#24565;&#65292;&#20989;&#25976;&#26159;&#19968;&#27573;&#12300;&#34987;&#21629;&#21517;&#12301;&#30340;&#31243;&#24335;&#30908;&#65292;&#36889;&#27573;&#31243;&#24335;&#30908;&#21487;&#20197;&#29992;&#26044;&#22519;&#34892;&#26576;&#20491;&#29305;&#23450;&#20219;&#21209;&#65292;&#21487;&#33021;&#26159;&#25976;&#20540;&#30340;&#36939;&#31639;&#25110;&#32773;&#25991;&#23383;&#30340;&#34389;&#29702;&#12290;&#25226;&#26576;&#38917;&#33021;&#22816;&#36939;&#20316;&#29305;&#23450;&#21151;&#33021;&#30340;&#31243;&#24335;&#30908;&#12300;&#21629;&#21517;&#12301;&#30340;&#27231;&#21046;&#65292;&#31281;&#20043;&#28858;&#32068;&#32340;&#31243;&#24335;&#30908;&#65292;&#22240;&#25033;&#19981;&#21516;&#30446;&#30340;&#20197;&#21450;&#25033;&#29992;&#22580;&#26223;&#65292; &#31243;&#24335;&#35373;&#35336;&#24107;&#26377;&#32068;&#32340;&#31243;&#24335;&#30908;&#30340;&#38656;&#27714;&#65292;&#24076;&#26395;&#21487;&#20197;&#31777;&#28500;&#19988;&#26377;&#25928;&#29575;&#22320;&#23436;&#25104;&#20219;&#21209;&#65292;&#20855;&#39636;&#20358;&#35498;&#65292;&#23601;&#26159;&#25552;&#21319;&#31243;&#24335;&#30908;&#30340;&#37325;&#35079;&#21033;&#29992;&#24615;&#65288;Reusability&#65289;&#12290;&#20107;&#23526;&#19978;&#65292;&#38500;&#20102;&#20989;&#25976;&#20197;&#22806;&#65292;Python &#33287;&#22823;&#22810;&#25976;&#30340;&#31243;&#24335;&#35486;&#35328;&#30456;&#21516;&#65292;&#25793;&#26377;&#20854;&#20182;&#32068;&#32340;&#31243;&#24335;&#30908;&#30340;&#27231;&#21046;&#65292;&#20855;&#39636;&#32780;&#35328;&#26377;&#19977;&#20491;&#23652;&#27425;&#65292;&#30001;&#23567;&#32780;&#22823;&#20381;&#24207;&#28858;&#65306;</p><ol><li><p>&#20989;&#25976;&#65288;Functions&#65289;&#12290;</p></li><li><p>&#39006;&#21029;&#65288;Classes&#65289;&#12290;</p></li><li><p>&#27169;&#32068;&#65288;Modules&#65289;&#12290;</p></li></ol><p>&#26412;&#31687;&#25991;&#31456;&#35201;&#20171;&#32057;&#32068;&#32340;&#31243;&#24335;&#30908;&#27231;&#21046;&#30340;&#31532;&#20108;&#20491;&#23652;&#27425;&#65306;<strong>&#39006;&#21029;</strong>&#12290;</p><h2>&#20160;&#40636;&#26159;&#39006;&#21029;</h2><p>&#25226;&#21363;&#23559;&#35201;&#22519;&#34892;&#30340;&#31243;&#24335;&#30908;&#32068;&#32340;&#28858;&#20989;&#25976;&#65292;&#20006;&#20381;&#24207;&#20351;&#29992;&#36889;&#20123;&#20989;&#25976;&#20358;&#23436;&#25104;&#20219;&#21209;&#65292;&#36889;&#26159;&#19968;&#31278;&#20197;&#20989;&#25976;&#28858;&#20027;&#39636;&#30340;&#31243;&#24335;&#35373;&#35336;&#39080;&#26684;&#65292;&#36889;&#27171;&#30340;&#25216;&#24039;&#31281;&#20043;&#28858;&#31243;&#24207;&#21270;&#31243;&#24335;&#35373;&#35336;&#65288;Procedural programming&#65289;&#65292;&#20063;&#26159;&#25105;&#20497;&#33267;&#20170;&#20197;&#20358;&#32722;&#24931;&#30340;&#23531;&#20316;&#26041;&#24335;&#65307;&#28982;&#32780;&#21478;&#22806;&#26377;&#19968;&#31278;&#31243;&#24335;&#35373;&#35336;&#39080;&#26684;&#65292;&#26159;&#25226;&#21363;&#23559;&#35201;&#22519;&#34892;&#30340;&#31243;&#24335;&#30908;&#32068;&#32340;&#28858;&#39006;&#21029;&#65288;Class&#65289;&#65292;&#20006;&#35222;&#25033;&#29992;&#22580;&#26223;&#20351;&#29992;&#39006;&#21029;&#20013;&#30340;&#26041;&#27861;&#25110;&#36039;&#26009;&#20358;&#23436;&#25104;&#20219;&#21209;&#65292;&#36889;&#27171;&#30340;&#25216;&#24039;&#31281;&#20043;&#28858;&#29289;&#20214;&#23566;&#21521;&#31243;&#24335;&#35373;&#35336;&#65288;Object-oriented programming, OOP&#65289;&#12290;&#20855;&#39636;&#32780;&#35328;&#65292;&#20551;&#22914;&#25105;&#20497;&#30340;&#31243;&#24335;&#30908;&#25152;&#38754;&#23565;&#35201;&#35299;&#27770;&#30340;&#21839;&#38988;&#26159;&#38750;&#24120;&#26126;&#30906;&#19988;&#23560;&#19968;&#30340;&#65292;&#37027;&#40636;&#20351;&#29992;&#31243;&#24207;&#21270;&#31243;&#24335;&#35373;&#35336;&#26159;&#24456;&#36969;&#30070;&#30340;&#65292;&#33289;&#20363;&#20358;&#35498;&#65292;&#22312;&#36092;&#36023;&#20992;&#20855;&#30340;&#26178;&#20505;&#65292;&#22914;&#26524;&#25105;&#20497;&#38750;&#24120;&#28165;&#26970;&#26159;&#35201;&#29992;&#20358;&#21066;&#27700;&#26524;&#30340;&#65292;&#23601;&#26371;&#36092;&#36023;&#19968;&#25226;&#27700;&#26524;&#20992;&#65307;&#21453;&#20043;&#22914;&#26524;&#31243;&#24335;&#30908;&#25152;&#38754;&#23565;&#35201;&#35299;&#27770;&#30340;&#21839;&#38988;&#26159;&#27604;&#36611;&#24291;&#27867;&#19988;&#22810;&#20803;&#30340;&#65292;&#37027;&#40636;&#20351;&#29992;&#29289;&#20214;&#23566;&#21521;&#31243;&#24335;&#35373;&#35336;&#23601;&#26371;&#26356;&#36028;&#36817;&#65292;&#33289;&#20363;&#20358;&#35498;&#65292;&#22312;&#36092;&#36023;&#20992;&#20855;&#30340;&#26178;&#20505;&#21482;&#30693;&#36947;&#33258;&#24049;&#26377;&#20351;&#29992;&#20992;&#20855;&#30340;&#38656;&#27714;&#65292;&#23601;&#26371;&#36092;&#36023;&#19968;&#20491;&#12300;&#20992;&#20855;&#32068;&#12301;&#25110;&#32773;&#12300;&#33836;&#33021;&#29790;&#22763;&#20992;&#12301;&#65292;&#24453;&#38656;&#27714;&#30332;&#29983;&#26178;&#65292;&#20877;&#24478;&#20854;&#20013;&#21462;&#20986;&#23565;&#25033;&#30340;&#20992;&#20358;&#20351;&#29992;&#12290;</p><h2>&#24120;&#29992;&#30340;&#39006;&#21029;</h2><p>&#22312; Python &#31243;&#24335;&#35373;&#35336;&#33287;&#36039;&#26009;&#20998;&#26512;&#30340;&#22580;&#26223;&#20013;&#65292;&#25105;&#20497;&#24120;&#29992;&#21040;&#30340;&#39006;&#21029;&#21487;&#20197;&#31895;&#30053;&#20998;&#28858;&#19977;&#31278;&#65306;</p><ol><li><p>&#20839;&#24314;&#30340;&#36039;&#26009;&#22411;&#21029;&#65306;&#25972;&#25976;&#12289;&#28014;&#40670;&#25976;&#12289;&#23383;&#20018;&#12289;&#24067;&#26519;&#33287; <code>NoneType</code>&#12290;</p></li><li><p>&#20839;&#24314;&#30340;&#36039;&#26009;&#32080;&#27083;&#65306;&#20018;&#21015;&#12289;<code>tuple</code>&#12289;&#23383;&#20856;&#33287;&#38598;&#21512;&#12290;</p></li><li><p>&#31532;&#19977;&#26041;&#27169;&#32068;&#30340;&#36039;&#26009;&#32080;&#27083;&#65306;&#22810;&#32173;&#24230;&#38499;&#21015;&#12289;<code>Index</code>&#12289;<code>Series</code> &#33287;&#36039;&#26009;&#26694;&#12290;</p></li></ol><p>&#31777;&#32780;&#35328;&#20043;&#65292;&#39006;&#21029;&#26159;&#19968;&#31278;&#33021;&#22816;&#35731;&#31243;&#24335;&#35373;&#35336;&#24107;&#33258;&#34892;&#23450;&#32681;&#36039;&#26009;&#22411;&#21029;&#25110;&#36039;&#26009;&#32080;&#27083;&#30340;&#27231;&#21046;&#65292;&#25552;&#20379;&#21487;&#20197;&#25226;&#36039;&#26009;&#33287;&#20989;&#25976;&#21253;&#35037;&#36215;&#20358;&#30340;&#26550;&#27083;&#65292;&#20006;&#22312;&#23450;&#32681;&#23436;&#21892;&#20197;&#24460;&#20351;&#29992;&#65292;&#20855;&#39636;&#30340;&#20351;&#29992;&#26041;&#24335;&#23601;&#26159;&#25105;&#20497;&#22312;&#19968;&#38283;&#22987;&#23416;&#32722;&#31243;&#24335;&#35373;&#35336;&#26178;&#25152;&#23416;&#26371;&#30340;&#12300;&#23459;&#21578;&#29289;&#20214;&#12301;&#65292;&#23436;&#25972;&#30340;&#35498;&#27861;&#26159;&#65306;&#29289;&#20214;&#65288;Object&#65289;&#26159;&#39006;&#21029;&#65288;Class&#65289;&#30340;&#23526;&#20363;&#65288;Instance&#65289;&#65292;&#39006;&#21029;&#20043;&#26044;&#29289;&#20214;&#30340;&#38364;&#20418;&#23601;&#20687;&#26159;&#34253;&#22294;&#20043;&#26044;&#29986;&#21697;&#12289;&#35373;&#35336;&#22294;&#20043;&#26044;&#25104;&#21697;&#25110;&#21407;&#31295;&#20043;&#26044;&#21360;&#21047;&#21697;&#19968;&#33324;&#12290;</p><pre><code># skywalker object is the instance of str
skywalker = "Anakin Skywalker" 
print(type(skywalker))
# skywalkers object is the instance of list
skywalkers = ["Anakin Skywalker", "Luke Skywalker"]
print(type(skywalkers))</code></pre><p>&#31243;&#24335;&#35373;&#35336;&#24107;&#33021;&#22816;&#20351;&#29992;&#39006;&#21029;&#21253;&#35037;&#36039;&#26009;&#33287;&#20989;&#25976;&#65292;&#21253;&#35037;&#22909;&#30340;&#36039;&#26009;&#31281;&#28858;&#29289;&#20214;&#30340;&#23660;&#24615;&#65288;Attributes&#65289;&#65292;&#21253;&#35037;&#22909;&#30340;&#20989;&#25976;&#31281;&#28858;&#29289;&#20214;&#30340;&#26041;&#27861;&#65288;Methods&#65289;&#12290;&#25105;&#20497;&#21487;&#20197;&#29992;&#20839;&#24314;&#20989;&#25976; <code>dir()</code> &#20358;&#27298;&#35222;&#26377;&#21738;&#20123;&#23660;&#24615;&#25110;&#26041;&#27861;&#12290;</p><pre><code>skywalker = "Luke Skywalker"
skywalkers = ["Anakin Skywalker", "Luke Skywalker"]
print(dir(skywalker))
print(dir(skywalkers))</code></pre><h2>&#20989;&#25976;&#33287;&#26041;&#27861;&#30340;&#20351;&#29992;</h2><p>&#25105;&#20497;&#21407;&#26412;&#25552;&#21040;&#30340;&#31243;&#24335;&#35373;&#35336;&#33287;&#36039;&#26009;&#20998;&#26512;&#26680;&#24515;&#31934;&#31070;&#65306;<strong>&#23565;&#36039;&#26009;&#25033;&#29992;&#20989;&#25976;</strong>&#65292;&#26159;&#20559;&#21521;&#31243;&#24207;&#21270;&#31243;&#24335;&#35373;&#35336;&#30340;&#35498;&#27861;&#65292;&#22312;&#26296;&#35299;&#39006;&#21029;&#35264;&#24565;&#20043;&#24460;&#65292;&#21516;&#27171;&#30340;&#26680;&#24515;&#31934;&#31070;&#21487;&#20197;&#20462;&#25913;&#28858;&#29289;&#20214;&#23566;&#21521;&#30340;&#35498;&#27861;&#65306;<strong>&#20351;&#29992;&#29289;&#20214;&#30340;&#26041;&#27861;</strong>&#12290;</p><p>&#22312; Python &#20013;&#20351;&#29992;&#20989;&#25976;&#26041;&#24335;&#26159;&#22312;&#20989;&#25976;&#21517;&#31281;&#24460;&#25509;&#19978;&#23567;&#25324;&#34399;&#65292;&#20006;&#22312;&#23567;&#25324;&#34399;&#20013;&#36664;&#20837;&#29289;&#20214;&#21517;&#31281;&#20197;&#21450;&#24341;&#25976;&#12290;</p><pre><code><code>function_name(OBJECT, ARGUMENTS)</code></code></pre><p>&#20351;&#29992;&#29289;&#20214;&#30340;&#26041;&#27861;&#26159;&#22312;&#29289;&#20214;&#21517;&#31281;&#24460;&#25509;&#19978;&#21477;&#34399;&#65288;.&#65289;&#20877;&#25509;&#19978;&#26041;&#27861;&#21517;&#31281;&#12289;&#23567;&#25324;&#34399;&#33287;&#24341;&#25976;&#12290;</p><pre><code><code>OBJECT.method_name(ARGUMENTS)</code></code></pre><p>&#20363;&#22914; Python &#26377;&#19968;&#20491;&#20839;&#24314;&#20989;&#25976;&nbsp;<code>sorted()</code>&#65292;&#20018;&#21015;&#26377;&#19968;&#20491;&#26041;&#27861;&nbsp;<code>sort()</code>&#65292;&#20841;&#32773;&#37117;&#33021;&#22816;&#25490;&#24207;&#19968;&#20491;&#20018;&#21015;&#65292;&#20294;&#26159;&#22312;&#20351;&#29992;&#30340;&#35486;&#27861;&#33287;&#24847;&#32681;&#19978;&#19981;&#21516;&#65292;&#20351;&#29992;&#20839;&#24314;&#20989;&#25976;&nbsp;<code>sorted()</code>&nbsp;&#25490;&#24207;&#20018;&#21015;&#26159;&#12300;&#23565;&#36039;&#26009;&#25033;&#29992;&#20989;&#25976;&#12301;&#30340;&#31243;&#24207;&#21270;&#31243;&#24335;&#35373;&#35336;&#35498;&#27861;&#65292;&#35486;&#27861;&#26159;&nbsp;<code>sorted(a_list_to_be_sorted)</code>&#65307;&#20351;&#29992;&#20018;&#21015;&#26041;&#27861;&nbsp;<code>sort()</code>&nbsp;&#25490;&#24207;&#26159;&#12300;&#20351;&#29992;&#29289;&#20214;&#30340;&#26041;&#27861;&#12301;&#30340;&#29289;&#20214;&#23566;&#21521;&#31243;&#24335;&#35373;&#35336;&#35498;&#27861;&#65292;&#35486;&#27861;&#26159;&nbsp;<code>a_list_to_be_sorted.sort()</code>&#12290;</p><pre><code><code>primes_list = [11, 7, 5, 3, 2]
sorted(primes_list) # Apply sorted function to primes_list
print(primes_list)  # primes_list is not sorted
primes_list.sort()  # Call sort method of primes_list
print(primes_list)  # primes_list was sorted</code></code></pre><p><code>&#20540;&#24471;&#27880;&#24847;&#30340;&#22320;&#26041;&#26159;&#65292;&#20351;&#29992;</code> <code>sorted()</code> <code>&#20989;&#25976;&#33287;&#20018;&#21015;&#30340;</code> <code>sort()</code> <code>&#26041;&#27861;&#20998;&#21029;&#34920;&#29694;&#20102;&#20841;&#31278;&#29289;&#20214;&#26356;&#21205;&#30340;&#32080;&#26524;&#65292;sorted(primes_list)</code>&nbsp;&#20197;&#22238;&#20659;&#20540;&#36664;&#20986;&#25490;&#24207;&#24460;&#30340;&#20018;&#21015;&#65292;&#22240;&#27492;&#22914;&#26524;&#27794;&#26377;&#23559;&#22238;&#20659;&#20540;&#26356;&#26032;&#21407;&#26412;&#21629;&#21517;&#30340;&#20018;&#21015;&#65292;&#25490;&#24207;&#30340;&#26356;&#21205;&#20006;&#19981;&#26371;&#34987;&#20445;&#30041;&#12290;&#32780;&nbsp;<code>primes.sort()</code>&nbsp;&#21063;&#26159;&#30452;&#25509;&#23559;&#25490;&#24207;&#26356;&#21205;&#20102;&#65292;&#19981;&#38656;&#35201;&#26356;&#26032;&#21407;&#26412;&#21629;&#21517;&#30340;&#20018;&#21015;&#65292;&#20063;&#19981;&#26371;&#20276;&#38568;&#26377;&#22238;&#20659;&#20540;&#12290;</p><h2>&#33258;&#34892;&#23450;&#32681;&#39006;&#21029;</h2><p>&#20351;&#29992;&#20445;&#30041;&#23383; <code>class</code> &#33021;&#22816;&#33258;&#34892;&#23450;&#32681;&#39006;&#21029;&#65292;&#21363;&#20415;&#25105;&#20497;&#36996;&#27794;&#26377;&#22312;&#39006;&#21029;&#35373;&#35336;&#20219;&#20309;&#36039;&#26009;&#25110;&#32773;&#20989;&#25976;&#65288;&#20677;&#20351;&#29992;&#20445;&#30041;&#23383; <code>pass</code> &#35731;&#33258;&#34892;&#23450;&#32681;&#39006;&#21029;&#30340;&#26550;&#27083;&#23436;&#25972;&#65289;&#65292;&#20294;&#20173;&#28982;&#21487;&#20197;&#29983;&#25104;&#19968;&#20491;&#12300;&#20160;&#40636;&#20107;&#37117;&#20570;&#19981;&#20102;&#12301;&#30340;&#39006;&#21029;&#65292;&#20540;&#24471;&#27880;&#24847;&#30340;&#26159;&#33258;&#34892;&#23450;&#32681;&#30340;&#39006;&#21029;&#21517;&#31281;&#25105;&#20497;&#32722;&#24931;&#20351;&#29992;&#39318;&#23383;&#22823;&#23531;&#30340;&#39389;&#23792;&#21629;&#21517;&#39080;&#26684;&#65288;Upper camel case&#65289;&#12290;</p><pre><code>class ClassName:
    pass</code></pre><p>&#20363;&#22914;&#33258;&#34892;&#23450;&#32681;&#19968;&#20491;&#31777;&#21934;&#35336;&#31639;&#27231;&#39006;&#21029; <code>SimpleCalculator</code>&#65292;&#22312;&#36889;&#20491;&#39006;&#21029;&#20013;&#21482;&#26377;&#19968;&#20491;&#35498;&#26126;&#25991;&#23383;&#12290;&#23436;&#25104;&#23450;&#32681;&#20197;&#24460;&#65292;&#25105;&#20497;&#23459;&#21578;&#20102;&#29289;&#20214; <code>sc</code> &#20316;&#28858; <code>SimpleCalculator</code> &#39006;&#21029;&#30340;&#23526;&#20363;&#65292;&#20006;&#19988;&#21033;&#29992;&#20839;&#24314;&#20989;&#25976; <code>type()</code> &#33287; <code>dir()</code> &#27298;&#35222;&#39006;&#21029;&#21517;&#31281;&#20197;&#21450;&#34987;&#21253;&#35037;&#30340;&#36039;&#26009;&#36319;&#20989;&#25976;&#12290;</p><pre><code>class SimpleCalculator:
    """
    This class creates a simple calculator that is unable to do anything.
    """
    pass

sc = SimpleCalculator()
print(type(sc))
print(dir(sc))</code></pre><p>&#24478;&#27298;&#35222;&#30340;&#32080;&#26524;&#25105;&#20497;&#21487;&#20197;&#30332;&#29694;&#33258;&#34892;&#23450;&#32681;&#39006;&#21029;&#38468;&#23660;&#26044; <code>__main__</code> &#20043;&#20013;&#65292;&#21516;&#26178;&#29289;&#20214; <code>sc</code> &#20063;&#20855;&#26377; <code>__doc__</code> &#20197;&#21450;&#20854;&#20182;&#35377;&#22810;&#21069;&#24460;&#37117;&#20855;&#26377;&#20841;&#20491;&#24213;&#32218;&#30340;&#23660;&#24615;&#25110;&#26041;&#27861;&#65292;&#21069;&#24460;&#37117;&#20855;&#26377;&#20841;&#20491;&#24213;&#32218;&#30340;&#21629;&#21517;&#25105;&#20497;&#31281;&#20043;&#28858; Python &#30340;&#29305;&#27530;&#21629;&#21517;&#65292;&#27604;&#36611;&#21934;&#32020;&#30340;&#29702;&#35299;&#26041;&#24335;&#28858; Python &#28858;&#20855;&#26377;&#29305;&#27530;&#29992;&#36884;&#30340;&#21151;&#33021;&#25152;&#20445;&#30041;&#30340;&#21629;&#21517;&#65292;&#28858;&#20102;&#36991;&#20813;&#21644;&#20351;&#29992;&#32773;&#30340;&#21629;&#21517;&#34909;&#31361;&#65292;&#29992;&#21069;&#24460;&#37117;&#20855;&#26377;&#20841;&#20491;&#24213;&#32218;&#30340;&#29305;&#27530;&#26684;&#24335;&#21312;&#38548;&#38283;&#65292;&#26410;&#20358;&#22914;&#26524;&#30475;&#21040;&#36889;&#27171;&#30340;&#21629;&#21517;&#65292;&#23601;&#30693;&#36947;&#26159; Python &#38928;&#35373;&#30340;&#21151;&#33021;&#12290;&#36889;&#26178;&#25105;&#20497;&#21487;&#20197;&#23559;&#29289;&#20214; <code>sc</code> &#30340; <code>__doc__</code> &#23660;&#24615;&#21360;&#20986;&#65292;&#26371;&#30475;&#21040;&#22312;&#33258;&#34892;&#23450;&#32681;&#39006;&#21029;&#20013;&#25152;&#23531;&#19979;&#30340;&#35498;&#26126;&#25991;&#23383;&#12290;</p><pre><code>print(sc.__doc__)</code></pre><h2>&#33258;&#34892;&#23450;&#32681;&#29289;&#20214;&#30340;&#26041;&#27861;</h2><p>&#22312;&#33258;&#34892;&#23450;&#32681;&#39006;&#21029;&#30340;&#31243;&#24335;&#21312;&#22602;&#20013;&#20351;&#29992;&nbsp;<code>def</code>&nbsp;&#20445;&#30041;&#23383;&#23559;&#20989;&#25976;&#33287;&#39006;&#21029;&#32129;&#23450;&#65292;&#20989;&#25976;&#19968;&#20294;&#34987;&#27512;&#23660;&#22312;&#39006;&#21029;&#24213;&#19979;&#65292;&#25104;&#28858;&#23526;&#20363;&#20043;&#24460;&#23601;&#26371;&#25913;&#31281;&#28858;&#29289;&#20214;&#30340;&#26041;&#27861;&#12290;</p><pre><code>class ClassName:
    def method(self):
        # ...</code></pre><p>&#36889;&#35041;&#29305;&#21029;&#27880;&#24847; <code>self</code> &#21443;&#25976;&#65292;&#30001;&#26044;&#22312;&#33258;&#34892;&#23450;&#32681;&#39006;&#21029;&#30340;&#38542;&#27573;&#65292;&#23601;&#26371;&#35373;&#35336;&#39006;&#21029;&#23526;&#20363;&#21270;&#28858;&#29289;&#20214;&#20043;&#24460;&#30340;&#20351;&#29992;&#34892;&#28858;&#65292;&#22240;&#27492;&#22312;&#35373;&#35336;&#38542;&#27573;&#24517;&#38920;&#35201;&#32102;&#20104;&#29289;&#20214;&#19968;&#20491;&#20195;&#21517;&#35422;&#65292;&#32780; <code>self</code> &#21443;&#25976;&#23601;&#26159;&#25198;&#28436;&#29289;&#20214;&#30340;&#20195;&#21517;&#35422;&#65288;&#20107;&#23526;&#19978; <code>self</code> &#21443;&#25976;&#21487;&#20197;&#20219;&#24847;&#22320;&#21629;&#21517;&#65292;&#20294;&#28858;&#20102;&#35731;&#31243;&#24335;&#30908;&#30340;&#21487;&#35712;&#24615;&#22686;&#21152;&#65292;&#25505;&#29992; <code>self</code> &#20570;&#21443;&#25976;&#21517;&#31281;&#26159;&#26368;&#20339;&#30340;&#26041;&#24335;&#65289;&#12290;&#31777;&#32780;&#35328;&#20043;&#65292;&#22914;&#26524;&#25105;&#20497;&#24076;&#26395;&#33258;&#34892;&#23450;&#32681;&#39006;&#21029;&#23526;&#20363;&#21270;&#28858;&#29289;&#20214;&#24460;&#21487;&#20197;&#36889;&#27171;&#20351;&#29992;&#65306;</p><pre><code>OBJECT.method(ARGUMENTS)</code></pre><p>&#22312;&#33258;&#34892;&#23450;&#32681;&#39006;&#21029;&#30340;&#38542;&#27573;&#65292;&#23601;&#35201;&#21152;&#20837; <code>self</code> &#21443;&#25976;&#20316;&#28858; <code>OBJECT</code> &#30340;&#20195;&#21517;&#35422;&#12290;&#20363;&#22914;&#33258;&#34892;&#23450;&#32681;&#30340;&#31777;&#21934;&#35336;&#31639;&#27231;&#39006;&#21029; <code>SimpleCalculator</code>&#65292;&#33509;&#26159;&#24076;&#26395;&#23526;&#20363;&#21270;&#29289;&#20214; <code>sc</code> &#21487;&#20197;&#36889;&#27171;&#20351;&#29992;&#65306;</p><pre><code>sc = SimpleCalculator()
sc.add(5, 6)</code></pre><p>&#23601;&#24517;&#38920;&#35201;&#22312;&#35373;&#35336;&#38542;&#27573;&#32013;&#20837; <code>self</code> &#21443;&#25976;&#20316;&#28858; <code>sc</code> &#30340;&#20195;&#21517;&#35422;&#12290;</p><pre><code>class SimpleCalculator:
    def add(self, a, b):
        return a + b

sc = SimpleCalculator()
print(sc.add(5, 6))</code></pre><h2>&#33258;&#34892;&#23450;&#32681;&#29289;&#20214;&#30340;&#23660;&#24615;</h2><p>&#22312;&#33258;&#34892;&#23450;&#32681;&#39006;&#21029;&#30340;&#31243;&#24335;&#21312;&#22602;&#20013;&#20351;&#29992;&#29305;&#27530;&#20989;&#25976; <code>__init__()</code> &#23559;&#36039;&#26009;&#33287;&#39006;&#21029;&#32129;&#23450;&#65292;&#36039;&#26009;&#19968;&#20294;&#34987;&#27512;&#23660;&#22312;&#39006;&#21029;&#24213;&#19979;&#65292;&#25104;&#28858;&#23526;&#20363;&#20043;&#24460;&#23601;&#26371;&#25913;&#31281;&#28858;&#29289;&#20214;&#30340;&#23660;&#24615;&#12290;</p><pre><code><code>class ClassName:
    def __init__(self, attribute):
        # ...</code></code></pre><p>&#36889;&#35041;&#29305;&#21029;&#27880;&#24847; <code>__init__()</code> &#29305;&#27530;&#20989;&#25976;&#65292;&#20063;&#24120;&#34987;&#31281;&#28858;&#24314;&#27083;&#22120;&#65288;Constructor&#65289;&#65292;&#36889;&#26159;&#22312;&#23559;&#39006;&#21029;&#23526;&#20363;&#21270;&#28858;&#29289;&#20214;&#30340;&#26178;&#20505;&#23601;&#26371;&#33258;&#21205;&#20351;&#29992;&#30340;&#20989;&#25976;&#65292;&#20063;&#22240;&#27492;&#25105;&#20497;&#21487;&#20197;&#22312;&#36889;&#20491;&#20989;&#25976;&#20043;&#19979;&#25226;&#36039;&#26009;&#37117;&#23459;&#21578;&#22949;&#30070;&#65292;&#30001;&#26044;&#36996;&#34389;&#26044;&#35373;&#35336;&#38542;&#27573;&#65292;&#21516;&#27171;&#33021;&#36879;&#36942; <code>self</code> &#21443;&#25976;&#20358;&#20316;&#28858;&#29289;&#20214;&#30340;&#20195;&#21517;&#35422;&#12290;&#31777;&#32780;&#35328;&#20043;&#65292;&#22914;&#26524;&#25105;&#20497;&#24076;&#26395;&#33258;&#34892;&#23450;&#32681;&#39006;&#21029;&#23526;&#20363;&#21270;&#28858;&#29289;&#20214;&#24460;&#21487;&#20197;&#36889;&#27171;&#20351;&#29992;&#65306;</p><pre><code>OBJECT.attribute</code></pre><p>&#22312;&#33258;&#34892;&#23450;&#32681;&#39006;&#21029;&#30340;&#38542;&#27573;&#65292;&#23601;&#35201;&#22312; <code>__init__()</code> &#20989;&#25976;&#19979;&#23559;&#36039;&#26009;&#33287; <code>self</code> &#32129;&#23450;&#12290;&#20363;&#22914;&#33258;&#34892;&#23450;&#32681;&#30340;&#31777;&#21934;&#35336;&#31639;&#27231;&#39006;&#21029; <code>SimpleCalculator</code>&#65292;&#33509;&#26159;&#24076;&#26395;&#23526;&#20363;&#21270;&#29289;&#20214; <code>sc</code> &#21487;&#20197;&#36889;&#27171;&#20351;&#29992;&#65306;</p><pre><code><code>sc = SimpleCalculator(5, 6)
print(sc.a)
print(sc.b)</code></code></pre><p>&#23601;&#24517;&#38920;&#35201;&#22312; <code>__init__()</code> &#20989;&#25976;&#19979;&#23559;&#21443;&#25976;&#23459;&#21578;&#28858; <code>self</code> &#30340;&#36039;&#26009;&#12290;</p><pre><code>class SimpleCalculator:
    def __init__(self, a, b):
        self.a = a
        self.b = b

sc = SimpleCalculator(5, 6)
print(sc.a)
print(sc.b)</code></pre><h2>&#22312;&#23450;&#32681;&#38542;&#27573;&#20351;&#29992;&#23660;&#24615;&#25110;&#26041;&#27861;</h2><p>&#33509;&#26159;&#22312;&#33258;&#34892;&#23450;&#32681;&#39006;&#21029;&#30340;&#38542;&#27573;&#20013;&#24819;&#35201;&#20351;&#29992;&#23660;&#24615;&#65292;&#21487;&#20197;&#22312;&#33258;&#34892;&#23450;&#32681;&#39006;&#21029;&#30340;&#31243;&#24335;&#21312;&#22602;&#20013;&#29992; <code>self.attribute</code> &#35486;&#27861;&#21462;&#29992;&#65292;&#20363;&#22914;&#23559;&#20841;&#20491;&#23660;&#24615;&#30456;&#21152;&#30340; <code>add()</code> &#26041;&#27861;&#21487;&#20197;&#36889;&#27171;&#23450;&#32681;&#65306;</p><pre><code>class SimpleCalculator:
    def __init__(self, a, b):
        self.a = a
        self.b = b
    def add(self):
        return self.a + self.b

sc = SimpleCalculator(5, 6)
print(sc.add())</code></pre><p>&#33509;&#26159;&#22312;&#33258;&#34892;&#23450;&#32681;&#39006;&#21029;&#30340;&#38542;&#27573;&#20013;&#24819;&#35201;&#20351;&#29992;&#26041;&#27861;&#65292;&#21487;&#20197;&#22312;&#33258;&#34892;&#23450;&#32681;&#39006;&#21029;&#30340;&#31243;&#24335;&#21312;&#22602;&#20013;&#29992; <code>self.method()</code> &#35486;&#27861;&#21462;&#29992;&#65292;&#20363;&#22914;&#23559;&#20841;&#20491;&#23660;&#24615;&#30456;&#21152;&#30340; <code>add()</code> &#26041;&#27861;&#33021;&#22816;&#35731; <code>add_and_square()</code> &#26041;&#27861;&#25509;&#32396;&#20351;&#29992;&#65306;</p><pre><code>class SimpleCalculator:
    def __init__(self, a, b):
        self.a = a
        self.b = b
    def add(self):
        return self.a + self.b
    def add_and_square(self):
        return (self.add())**2

sc = SimpleCalculator(5, 6)
print(sc.add_and_square())</code></pre><h2>&#35373;&#35336;&#23526;&#20363;&#21270;&#24460;&#29289;&#20214;&#30340;&#39023;&#31034;&#22806;&#35264;</h2><p>&#33258;&#34892;&#23450;&#32681;&#39006;&#21029;&#26371;&#20855;&#26377;&#19968;&#20491;&#21517;&#28858; <code>__repr__()</code> &#30340;&#29305;&#27530;&#20989;&#25976;&#65292;&#23427;&#36319;&#21069;&#38754;&#20986;&#29694;&#36942;&#30340; <code>__doc__</code> &#23660;&#24615;&#20197;&#21450; <code>__init__()</code> &#26041;&#27861;&#37117;&#23660;&#26044;&#39006;&#21029;&#20013;&#38928;&#35373;&#20316;&#28858;&#26576;&#20491;&#21151;&#33021;&#30340;&#29305;&#27530;&#21629;&#21517;&#65292;&#20687;&#26159; <code>__doc__</code> &#23660;&#24615;&#34987;&#20445;&#30041;&#32102;&#39006;&#21029;&#30340;&#35498;&#26126;&#25991;&#23383;&#65292;<code>__init__()</code> &#26041;&#27861;&#34987;&#20445;&#30041;&#32102;&#39006;&#21029;&#23526;&#20363;&#21270;&#28858;&#29289;&#20214;&#26178;&#26371;&#33258;&#21205;&#20351;&#29992;&#30340;&#20989;&#25976;&#12290;&#32780; <code>__repr__()</code> &#20989;&#25976;&#30340;&#20316;&#29992;&#23601;&#26159;&#35373;&#35336;&#23526;&#20363;&#21270;&#24460;&#29289;&#20214;&#30340;&#39023;&#31034;&#22806;&#35264;&#65292;&#25105;&#20497;&#39318;&#20808;&#23559;&#21069;&#36848;&#27794;&#26377;&#23450;&#32681; <code>__repr__()</code> &#30340;&#29289;&#20214;&#21360;&#20986;&#20358;&#27298;&#35222;&#65306;</p><pre><code>class SimpleCalculator:
    def __init__(self, a, b):
        self.a = a
        self.b = b
    def add(self):
        return self.a + self.b
    def add_and_square(self):
        return (self.add())**2

sc = SimpleCalculator(5, 6)
print(sc)</code></pre><p>&#30446;&#21069;&#30475;&#21040;&#30340;&#26159;&#19968;&#20491;&#27794;&#26377;&#35387;&#26126;&#35442;&#22914;&#20309;&#39023;&#31034;&#29289;&#20214;&#22806;&#35264;&#30340;&#29376;&#24907;&#65292;&#22240;&#28858;&#22312;&#35373;&#35336;&#39006;&#21029;&#30340;&#36942;&#31243;&#20013;&#65292;&#20006;&#27794;&#26377;&#22312;&#20854;&#20013;&#23450;&#32681; <code>__repr__()</code> &#20989;&#25976;&#12290;</p><p>&#25509;&#33879;&#23559;&#23450;&#32681; <code>__repr__()</code> &#20989;&#25976;&#21152;&#20837;&#21040;&#39006;&#21029;&#20043;&#20013;&#65292;&#20877;&#23559;&#26377;&#23450;&#32681; <code>__repr__(</code>) &#20989;&#25976;&#24460;&#30340;&#39006;&#21029;&#23526;&#20363;&#21270;&#28858;&#29289;&#20214;&#21360;&#20986;&#20358;&#27298;&#35222;&#65306;</p><pre><code>class SimpleCalculator:
    def __init__(self, a, b):
        self.a = a
        self.b = b
    def __repr__(self):
        return "a: {}, b: {}".format(self.a, self.b)
    def add(self):
        return self.a + self.b
sc = SimpleCalculator(5, 6)
print(sc)</code></pre><p>&#26377;&#28961;&#23450;&#32681; <code>__repr__()</code> &#20989;&#25976;&#24046;&#30064;&#19968;&#30446;&#30637;&#28982;&#12290;</p><h2>&#23553;&#35037;&#33287;&#32380;&#25215;</h2><p>&#21069;&#36848;&#25105;&#20497;&#36879;&#36942;&#33258;&#34892;&#23450;&#32681;&#39006;&#21029;&#33021;&#22816;&#23559;&#36039;&#26009;&#33287;&#20989;&#25976;&#20998;&#21029;&#21253;&#35037;&#25104;&#28858;&#39006;&#21029;&#30340;&#29289;&#20214;&#23660;&#24615;&#65288;Attributes&#65289;&#20197;&#21450;&#39006;&#21029;&#30340;&#29289;&#20214;&#26041;&#27861;&#65288;Methods&#65289;&#65292;&#36889;&#27171;&#25226;&#20989;&#25976;&#23526;&#20316;&#32048;&#31680;&#21253;&#35037;&#12289;&#38577;&#34255;&#36215;&#20358;&#30340;&#31243;&#24335;&#30908;&#29305;&#24615;&#31281;&#28858;&#23553;&#35037;&#65288;Encapsulation&#65289;&#12290;</p><p>&#21478;&#22806;&#19968;&#31278;&#39006;&#21029;&#25152;&#20855;&#20633;&#30340;&#31243;&#24335;&#30908;&#29305;&#24615;&#31281;&#28858;&#32380;&#25215;&#65288;Inheritance&#65289;&#65292;&#36889;&#26159;&#29992;&#20358;&#35731;&#20808;&#21069;&#23450;&#32681;&#22909;&#30340;&#39006;&#21029;&#24471;&#20197;&#24310;&#23637;&#21151;&#33021;&#30340;&#27231;&#21046;&#65292;&#36879;&#36942;&#32380;&#25215;&#65292;&#26032;&#23450;&#32681;&#30340;&#39006;&#21029;&#21487;&#20197;&#23436;&#20840;&#27839;&#35186;&#25152;&#32380;&#25215;&#39006;&#21029;&#30340;&#23660;&#24615;&#33287;&#26041;&#27861;&#65292;&#36889;&#27171;&#23376;&#21487;&#20197;&#26377;&#25928;&#35299;&#27770;&#31243;&#24335;&#30908;&#30340;&#37325;&#35079;&#24615;&#21839;&#38988;&#65292;&#20006;&#19988;&#23526;&#36368;&#36575;&#39636;&#24037;&#31243;&#30340; DRY(Don&#8217;t Repeat Yourself) &#21746;&#23416;&#12290;</p><p>&#21482;&#38656;&#35201;&#22312;&#26032;&#23450;&#32681;&#39006;&#21029;&#30340;&#21517;&#31281;&#24460;&#22312;&#23567;&#25324;&#34399;&#20839;&#20195;&#20837;&#24050;&#23450;&#32681;&#23436;&#25104;&#30340;&#39006;&#21029;&#65292;&#21363;&#21487;&#20687;&#26159;&#12300;&#35079;&#35069;&#12301;&#19968;&#33324;&#25226;&#26082;&#26377;&#39006;&#21029;&#30340;&#25152;&#26377;&#21151;&#33021;&#22312;&#26032;&#23450;&#32681;&#39006;&#21029;&#20013;&#23526;&#29694;&#65292;&#30001;&#26044;&#36889;&#20491;&#27231;&#21046;&#20351;&#29992;&#20102;&#12300;&#32380;&#25215;&#12301;&#36889;&#20491;&#21205;&#35422;&#65292;&#25152;&#20197;&#24120;&#23559;&#24050;&#23450;&#32681;&#23436;&#25104;&#30340;&#39006;&#21029;&#31281;&#28858;&#29238;&#27597;&#39006;&#21029;&#65288;ParentClass&#65289;&#12289;&#32780;&#23559;&#26032;&#23450;&#32681;&#39006;&#21029;&#31281;&#28858;&#23376;&#22899;&#39006;&#21029;&#65288;ChildClass&#65289;&#12290;</p><pre><code><code>class ChildClass(ParentClass):
    # ...</code></code></pre><p>&#33289;&#20363;&#20358;&#35498;&#65292;&#23450;&#32681;&#22909;&#30340;&#39006;&#21029;&nbsp;<code>SimpleCalculator</code>&nbsp;&#20855;&#26377; __init__()&#12289;__repr__() &#33287; add() &#36889;&#19977;&#20491;&#26041;&#27861;&#20197;&#21450; a &#33287; b &#20841;&#20491;&#23660;&#24615;&#65307;&#32380;&#25215;&#20102;&nbsp;<code>SimpleCalculator</code>&nbsp;&#30340;&nbsp;<code>AnotherSimpleCalculator</code>&nbsp;&#39006;&#21029;&#22312;&#20160;&#40636;&#20107;&#37117;&#19981;&#20570;&#30340;&#24773;&#27841;&#19979;&#65288;&#20677;&#20659;&#20837;&#19968;&#20491;&nbsp;<code>pass</code>&nbsp;&#20445;&#30041;&#23383;&#65289;&#23601;&#20855;&#20633;&#20102;&#19977;&#20491;&#26041;&#27861;&#20197;&#21450;&#20841;&#20491;&#23660;&#24615;&#65306;</p><pre><code><code>class AnotherSimpleCalculator(SimpleCalculator):
    pass

another_sc = AnotherSimpleCalculator(5, 6)
print(another_sc)
print(another_sc.add())
print(another_sc.a)
print(another_sc.b)</code></code></pre><p>&#22914;&#27492;&#19968;&#20358;&#22312;&#26032;&#23450;&#32681;&#30340;&#39006;&#21029;&#20013;&#28155;&#21152;&#26041;&#27861;&#65292;&#23601;&#21487;&#20197;&#24341;&#29992;&#32380;&#25215;&#32780;&#20358;&#30340;&#26041;&#27861;&#20197;&#21450;&#23660;&#24615;&#65292;&#36948;&#21040;&#21151;&#33021;&#24310;&#23637;&#20006;&#19988;&#19981;&#38656;&#35201;&#37325;&#26032;&#36896;&#36650;&#30340;&#36575;&#39636;&#24037;&#31243; DRY(Don&#8217;t Repeat Yourself) &#21746;&#23416;&#12290;</p><p>&#22312;&#21021;&#27493;&#35469;&#35672;&#20102;&#39006;&#21029;&#20043;&#24460;&#65292;&#31532;&#21313;&#19971;&#36913;&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#30340;&#20989;&#25976;&#20358;&#21040;&#23614;&#32882;&#65292;&#24076;&#26395;&#24744;&#20063;&#21644;&#25105;&#19968;&#27171;&#26399;&#24453;&#19979;&#19968;&#31687;&#25991;&#31456;&#12290;</p><h2>&#24310;&#20280;&#38321;&#35712;</h2><ul><li><p><a href="https://docs.python.org/3/tutorial/classes.html">https://docs.python.org/3/tutorial/classes.html</a></p></li></ul><div><hr></div><p>&#23565;&#26044;&#36889;&#31687;&#25991;&#31456;&#26377;&#20160;&#40636;&#24819;&#27861;&#21602;&#65311;&#21916;&#27489;&#128571;&#12289;&#30041;&#35328;&#128587;&#8205;&#9794;&#65039;&#25110;&#32773;&#20998;&#20139;&#128588;</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://datainpoint.substack.com/p/week-seventeen-classes-in-python/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://datainpoint.substack.com/p/week-seventeen-classes-in-python/comments"><span>Leave a comment</span></a></p><h2>&#35336;&#30059;&#23416;&#21729;&#23560;&#21312;</h2><p>&#20184;&#36027;&#35330;&#38321;&#38651;&#23376;&#22577;&#30340;&#26371;&#21729;&#21487;&#20197;&#40670;&#36984; nbgitpuller &#36899;&#32080;&#23559;&#26412;&#31687;&#25991;&#31456;&#23436;&#25972;&#30340; Jupyter Notebook &#35079;&#35069;&#21040;&#33258;&#24049;&#30340; Jupyter Server&#65306;</p><p><a href="https://lab.datainpoint.com/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fdatainpoint%2Fweek-seventeen-classes-in-python&amp;urlpath=tree%2Fweek-seventeen-classes-in-python%2Fnotebook.ipynb&amp;branch=main">nbgitpuller &#36899;&#32080;</a></p><p>&#20282;&#26381;&#22120;&#36984;&#38917;&#36984;&#25799;&#38928;&#35373;&#30340;&#12300;Data science environment&#65306;&#23416;&#32722; Python&#12289;R &#33287; Julia &#30340;&#36039;&#26009;&#31185;&#23416;&#29872;&#22659;&#12301;&#23601;&#21487;&#20197;&#38918;&#21033;&#36939;&#20316;&#25991;&#31456;&#20013;&#30340;&#31684;&#20363;&#31243;&#24335;&#12290;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HMwv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HMwv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 424w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 848w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1272w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!HMwv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png" width="1456" height="964" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:964,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:137396,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!HMwv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 424w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 848w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1272w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#36984;&#25799;&#12300;Data science environment&#65306;&#23416;&#32722; Python&#12289;R &#33287; Julia &#30340;&#36039;&#26009;&#31185;&#23416;&#29872;&#22659;&#12301;</figcaption></figure></div>]]></content:encoded></item><item><title><![CDATA[約維安計畫：Python 的函數]]></title><description><![CDATA[&#31532;&#21313;&#20845;&#36913;&#12290;]]></description><link>https://datainpoint.substack.com/p/week-sixteen-functions-in-python</link><guid isPermaLink="false">https://datainpoint.substack.com/p/week-sixteen-functions-in-python</guid><dc:creator><![CDATA[Yao-Jen Kuo]]></dc:creator><pubDate>Wed, 01 Sep 2021 09:12:09 GMT</pubDate><enclosure url="https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/6bf80f24-6222-4763-9a0f-83c723a6ad58_480x270.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!CCne!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F86906835-efd7-40b0-90b1-5bea89ec4d04_480x270.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!CCne!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F86906835-efd7-40b0-90b1-5bea89ec4d04_480x270.gif 424w, https://substackcdn.com/image/fetch/$s_!CCne!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F86906835-efd7-40b0-90b1-5bea89ec4d04_480x270.gif 848w, https://substackcdn.com/image/fetch/$s_!CCne!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F86906835-efd7-40b0-90b1-5bea89ec4d04_480x270.gif 1272w, https://substackcdn.com/image/fetch/$s_!CCne!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F86906835-efd7-40b0-90b1-5bea89ec4d04_480x270.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!CCne!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F86906835-efd7-40b0-90b1-5bea89ec4d04_480x270.gif" width="480" height="270" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/86906835-efd7-40b0-90b1-5bea89ec4d04_480x270.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:270,&quot;width&quot;:480,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:4795734,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!CCne!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F86906835-efd7-40b0-90b1-5bea89ec4d04_480x270.gif 424w, https://substackcdn.com/image/fetch/$s_!CCne!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F86906835-efd7-40b0-90b1-5bea89ec4d04_480x270.gif 848w, https://substackcdn.com/image/fetch/$s_!CCne!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F86906835-efd7-40b0-90b1-5bea89ec4d04_480x270.gif 1272w, https://substackcdn.com/image/fetch/$s_!CCne!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F86906835-efd7-40b0-90b1-5bea89ec4d04_480x270.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#20358;&#28304;&#65306;giphy.com</figcaption></figure></div><p>&#22312;<a href="https://datainpoint.substack.com/p/week-twelve-getting-started-with-python">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#36215;&#27493;&#36208;</a>&#25105;&#20497;&#36879;&#36942;&nbsp;<code>print("Hello, World!") &#20358;</code>&#30906;&#35469; Python &#30340;&#38283;&#30332;&#29872;&#22659;&#21450;&#22519;&#34892;&#29872;&#22659;&#26159;&#21542;&#24050;&#32147;&#23433;&#35037;&#22949;&#30070;&#65292;&#22312;&#36889;&#19968;&#27573;&#21704;&#22217;&#19990;&#30028;&#30340;&#31243;&#24335;&#30908;&#20013;&#65292;&#20854;&#23526;&#23601;&#33021;&#39636;&#39511;&#31243;&#24335;&#35373;&#35336;&#33287;&#36039;&#26009;&#20998;&#26512;&#30340;&#19968;&#20491;&#26680;&#24515;&#31934;&#31070;&#65306;<strong>&#23565;&#36039;&#26009;&#25033;&#29992;&#20989;&#25976;</strong>&#12290;</p><p><code>print</code>&nbsp;&#26159;&#20989;&#25976;&#30340;&#21517;&#31281;&#65292;<code>print()</code>&nbsp;&#21063;&#34920;&#31034;&#35201;&#25033;&#29992;&#35442;&#20989;&#25976;&#30340;&#21151;&#33021;&#65292;&#32780;&nbsp;<code>&#8220;Hello, World!&#8220;</code>&nbsp;&#21063;&#26159;&#19968;&#20491;&#34987;&#31281;&#21628;&#28858;&#23383;&#20018;&#65288;String&#65289;&#30340;&#36039;&#26009;&#22411;&#21029;&#65307;&#25563;&#35328;&#20043;&#65292;&#21704;&#22217;&#19990;&#30028;&#21487;&#20197;&#34920;&#36948;&#28858;&#65306;&#23565;&nbsp;<code>&#8220;Hello, World!&#8220;</code>&nbsp;&#36889;&#20491;&#23383;&#20018;&#25033;&#29992;&#20102;&nbsp;<code>print</code>&nbsp;&#20989;&#25976;&#12290;</p><pre><code><code>print("Hello, World!")</code></code></pre><h2>&#20160;&#40636;&#26159;&#20989;&#25976;</h2><p>&#20989;&#25976;&#26159;&#27083;&#25104;&#25152;&#26377;&#31243;&#24335;&#35486;&#35328;&#30340;&#22522;&#26412;&#35201;&#32032;&#65292;&#19968;&#20491;&#20989;&#25976;&#26159;&#19968;&#27573;&#12300;&#34987;&#21629;&#21517;&#12301;&#30340;&#31243;&#24335;&#30908;&#65292;&#36889;&#27573;&#31243;&#24335;&#30908;&#21487;&#20197;&#29992;&#26044;&#22519;&#34892;&#26576;&#20491;&#29305;&#23450;&#20219;&#21209;&#65292;&#21487;&#33021;&#26159;&#25976;&#20540;&#30340;&#36939;&#31639;&#25110;&#32773;&#25991;&#23383;&#30340;&#34389;&#29702;&#65292;&#30070;&#20351;&#29992;&#32773;&#24819;&#35201;&#25033;&#29992;&#65288;&#20351;&#29992;&#12289;&#21628;&#21483;&#65289;&#26576;&#19968;&#20491;&#20989;&#25976;&#20043;&#21069;&#65292;&#24517;&#38920;&#20808;&#30906;&#23450;&#22312;&#20316;&#29992;&#22495;&#20013;&#35442;&#20989;&#25976;&#24050;&#32147;&#34987;&#23450;&#32681;&#25110;&#32773;&#34987;&#36617;&#20837;&#12290;&#31777;&#32780;&#35328;&#20043;&#65292;&#22312;&#21704;&#22217;&#19990;&#30028;&#30340;&#31243;&#24335;&#30908;&#20013;&#65292;&#20043;&#25152;&#20197;&#33021;&#22816;&#23565;&#23383;&#20018;&nbsp;<code>&#8220;Hello, World!&#8220;</code>&nbsp;&#25033;&#29992;&nbsp;<code>print</code>&nbsp;&#20989;&#25976;&#65292;&#26159;&#22240;&#28858;&nbsp;<code>print</code>&nbsp;&#20989;&#25976;&#23660;&#26044; Python &#30340;&#20839;&#24314;&#20989;&#25976;&#65292;&#22312; Python &#21855;&#21205;&#30340;&#30070;&#19979;&#23601;&#26371;&#34987;&#36617;&#20837;&#20379;&#25105;&#20497;&#20351;&#29992;&#65292;&#20839;&#24314;&#20989;&#25976;&#22810;&#36948; 74 &#20491;&#65292;&#25152;&#26377;&#30340;&#20839;&#24314;&#20989;&#25976;&#33287;&#35443;&#32048;&#20171;&#32057;&#21487;&#20197;&#21443;&#32771;&#65306;<a href="https://docs.python.org/3/library/functions.html">https://docs.python.org/3/library/functions.html</a>&#12290;</p><h2>&#20989;&#25976;&#30340;&#20841;&#31278;&#20351;&#29992;&#26041;&#24335;</h2><p>&#22312; Python &#20013;&#26368;&#24120;&#35211;&#30340;&#20989;&#25976;&#20351;&#29992;&#26041;&#24335;&#26159;&#22312;&#20989;&#25976;&#21517;&#31281;&#24460;&#25509;&#19978;&#23567;&#25324;&#34399;&#65292;&#20006;&#22312;&#23567;&#25324;&#34399;&#20013;&#36664;&#20837;&#29289;&#20214;&#21517;&#31281;&#65288;&#35442;&#29289;&#20214;&#25152;&#20786;&#23384;&#30340;&#21487;&#33021;&#26159;&#26576;&#20491;&#36039;&#26009;&#22411;&#21029;&#25110;&#32773;&#36039;&#26009;&#32080;&#27083;&#65289;&#20197;&#21450;&#24341;&#25976;&#65288;&#22914;&#26524;&#20989;&#25976;&#26377;&#20219;&#20309;&#21443;&#25976;&#35373;&#35336;&#65289;&#12290;</p><pre><code>function_name(OBJECT, ARGUMENTS)</code></pre><p>&#30001;&#26044; Python &#23660;&#26044;&#29289;&#20214;&#23566;&#21521;&#65288;Object-oriented&#65289;&#31243;&#24335;&#35486;&#35328;&#65292;&#31532;&#20108;&#31278;&#20989;&#25976;&#23450;&#32681;&#30340;&#24418;&#24335;&#26159;&#32129;&#23450;&#26044;&#29289;&#20214;&#20043;&#19978;&#65292;&#36889;&#26178;&#20505;&#20351;&#29992;&#30340;&#26041;&#24335;&#23601;&#35722;&#25104;&#20102;&#22312;&#29289;&#20214;&#21517;&#31281;&#24460;&#25509;&#19978;&#38468;&#23660;&#31526;&#34399;&#65288;.&#65289;&#20877;&#25509;&#19978;&#20989;&#25976;&#21517;&#31281;&#12289;&#23567;&#25324;&#34399;&#33287;&#24341;&#25976;&#65288;&#22914;&#26524;&#20989;&#25976;&#26377;&#20219;&#20309;&#21443;&#25976;&#35373;&#35336;&#65289;&#65292;&#22312;&#31532;&#20108;&#31278;&#24418;&#24335;&#20013;&#65292;&#19981;&#21482;&#22312;&#20351;&#29992;&#19978;&#30340;&#35486;&#27861;&#30456;&#30064;&#65292;&#22312;&#31281;&#21628;&#19978;&#25105;&#20497;&#20063;&#19981;&#20877;&#29992;&#12300;&#20989;&#25976;&#12301;&#65292;&#32780;&#26159;&#25913;&#31281;&#29289;&#20214;&#30340;&#12300;&#26041;&#27861;&#12301;&#12290;</p><pre><code>OBJECT.method_name(ARGUMENTS)</code></pre><p>&#20363;&#22914; Python &#26377;&#19968;&#20491;&#20839;&#24314;&#20989;&#25976;&nbsp;<code>sorted()</code>&#65292;&#20018;&#21015;&#26377;&#19968;&#20491;&#26041;&#27861;&nbsp;<code>sort()</code>&#65292;&#20841;&#32773;&#37117;&#33021;&#22816;&#25490;&#24207;&#19968;&#20491;&#20018;&#21015;&#65292;&#20294;&#26159;&#22312;&#20351;&#29992;&#30340;&#35486;&#27861;&#33287;&#24847;&#32681;&#19978;&#19981;&#21516;&#65292;&#20351;&#29992;&#20839;&#24314;&#20989;&#25976;&nbsp;<code>sorted()</code>&nbsp;&#25490;&#24207;&#20018;&#21015;&#26159;&#25105;&#20497;&#32722;&#24931;&#19988;&#30452;&#35264;&#30340;&#12300;&#23565;&#36039;&#26009;&#32080;&#27083;&#25033;&#29992;&#20989;&#25976;&#12301;&#65292;&#35486;&#27861;&#26159;&nbsp;<code>sorted(a_list_to_be_sorted)</code>&#65307;&#20351;&#29992;&#20018;&#21015;&#26041;&#27861;&nbsp;<code>sort()</code>&nbsp;&#25490;&#24207;&#26159;&#30446;&#21069;&#36611;&#38476;&#29983;&#30340;&#12300;&#20351;&#29992;&#32129;&#23450;&#26044;&#36039;&#26009;&#32080;&#27083;&#30340;&#26041;&#27861;&#12301;&#65292;&#35486;&#27861;&#26159;&nbsp;<code>a_list_to_be_sorted.sort()</code>&#12290;&#36889;&#31687;&#25991;&#31456;&#20013;&#25105;&#20497;&#23560;&#27880;&#26044;&#33258;&#34892;&#23450;&#32681;&#30340;&#20989;&#25976;&#65292;&#33258;&#34892;&#23450;&#32681;&#29289;&#20214;&#30340;&#26041;&#27861;&#25105;&#20497;&#26371;&#22312;&#12300;&#39006;&#21029;&#12301;&#20027;&#38988;&#26178;&#35527;&#21040;&#12290;</p><pre><code><code>primes_list = [11, 7, 5, 3, 2]
sorted(primes_list) # Apply sorted function to primes_list primes_list.sort()  # Call sort method of primes_list</code></code></pre><h2>&#21443;&#25976;&#33287;&#24341;&#25976;&#30340;&#24046;&#21029;</h2><p>&#22312;&#25490;&#24207;&#20018;&#21015;&#30340;&#26178;&#20505;&#65292;&#25105;&#20497;&#21487;&#20197;&#36984;&#25799;&#35201;&#12300;&#36958;&#22686;&#22320;&#12301;&#25490;&#24207;&#25110;&#32773;&#12300;&#36958;&#28187;&#22320;&#12301;&#25490;&#24207;&#65292;&#36889;&#21487;&#20197;&#36879;&#36942;&#20659;&#20837;&#30340;&#24341;&#25976;&#65288;Arguments&#65289;&#35519;&#25972;&#20989;&#25976;&#30340;&#21443;&#25976;&#65288;Parameters&#65289;&#65292;&#20855;&#39636;&#20358;&#35498;&#65292;&#20989;&#25976;&#22312;&#23450;&#32681;&#30340;&#38542;&#27573;&#38656;&#35201;&#20351;&#29992;&#30340;&#36039;&#26009;&#22411;&#21029;&#25110;&#36039;&#26009;&#32080;&#27083;&#31281;&#28858;&#21443;&#25976;&#65292;&#22312;&#20351;&#29992;&#30340;&#38542;&#27573;&#38656;&#35201;&#25351;&#23450;&#32102;&#21443;&#25976;&#30340;&#36039;&#26009;&#22411;&#21029;&#25110;&#36039;&#26009;&#32080;&#27083;&#23601;&#31281;&#28858;&#24341;&#25976;&#12290;</p><pre><code><code>def function_name(parameter_1, parameter_2):
    # body of the function
    # ...
    # ...sequence of statements

function_name(argument_1, argument_2)</code></code></pre><p>&#36890;&#24120;&#21443;&#25976;&#26371;&#32102;&#20104;&#38928;&#35373;&#20540;&#65292;&#20363;&#22914; <code>sorted()</code> &#20989;&#25976;&#33287;&#20018;&#21015;&#30340; <code>sort()</code> &#26041;&#27861;&#37117;&#20855;&#26377; <code>reverse</code> &#21443;&#25976;&#65292;&#38928;&#35373;&#20540;&#32102;&#23450;&#28858; <code>True</code>&#12290;&#25152;&#20197;&#22312;&#27794;&#26377;&#20659;&#20837;&#24341;&#25976;&#30340;&#29376;&#27841;&#19979;&#65292;&#20854;&#23526;&#23601;&#26159;&#25505;&#29992; <code>reverse=False</code> &#30340;&#21443;&#25976;&#35373;&#23450;&#65292;&#20551;&#20351;&#19981;&#24819;&#25505;&#29992;&#38928;&#35373;&#20540;&#65292;&#23601;&#33021;&#36984;&#25799;&#20197;&#21517;&#31281;&#65288;Named&#65289;&#21443;&#25976;&#20358;&#20659;&#20837;&#24341;&#25976;&#12290;</p><pre><code>primes_list = [11, 7, 5, 3, 2]
sorted(primes_list)
sorted(primes_list, reverse=True) # Named
primes_list.sort()
primes_list.sort(reverse=True) # Named</code></pre><h2>&#26356;&#21205;&#32080;&#26524;&#30340;&#27231;&#21046;</h2><p>&#38500;&#20102;&#20351;&#29992;&#12300;&#20989;&#25976;&#12301;&#25110;&#12300;&#26041;&#27861;&#12301;&#30340;&#24046;&#30064;&#65292;&#21478;&#22806;&#20540;&#24471;&#27880;&#24847;&#20043;&#34389;&#22312;&#26044;&#20989;&#25976;&#33287;&#26041;&#27861;&#30340;&#20351;&#29992;&#37117;&#21487;&#33021;&#35731;&#25033;&#29992;&#25110;&#25152;&#23660;&#30340;&#29289;&#20214;&#36896;&#25104;&#26356;&#21205;&#65292;&#19968;&#31278;&#26356;&#21205;&#26041;&#24335;&#26159;&#20197;&#22238;&#20659;&#20540;&#22411;&#24907;&#36664;&#20986;&#26356;&#21205;&#24460;&#30340;&#32080;&#26524;&#65307;&#21478;&#19968;&#31278;&#26356;&#21205;&#26041;&#24335;&#26159;&#30452;&#25509;&#26356;&#21205;&#36039;&#26009;&#22411;&#21029;&#33287;&#36039;&#26009;&#32080;&#27083;&#32780;&#27794;&#26377;&#36664;&#20986;&#12290;&#36889;&#20491;&#24046;&#30064;&#33021;&#22816;&#24310;&#32396;&#21069;&#36848;&#20839;&#24314;&#20989;&#25976;&nbsp;<code>sorted()</code>&nbsp;&#33287;&#20018;&#21015;&#26041;&#27861;&nbsp;<code>sort()</code>&nbsp;&#30340;&#20363;&#23376;&#65292;<code>sorted(a_list_to_be_sorted)</code>&nbsp;&#26159;&#20197;&#22238;&#20659;&#20540;&#36664;&#20986;&#25490;&#24207;&#24460;&#30340;&#20018;&#21015;&#65292;&#22240;&#27492;&#22914;&#26524;&#27794;&#26377;&#23559;&#22238;&#20659;&#20540;&#26356;&#26032;&#21407;&#26412;&#21629;&#21517;&#30340;&#20018;&#21015;&#65292;&#25490;&#24207;&#30340;&#26356;&#21205;&#20006;&#19981;&#26371;&#34987;&#20445;&#30041;&#12290;</p><pre><code><code>primes_list = [11, 7, 5, 3, 2]
sorted(primes_list) # Apply sorted function to primes_list print(primes_list)  # primes_list is not sorted 
primes_list = sorted(primes_list)  # Update primes_list with function output
print(primes_list)  # primes_list is sorted</code></code></pre><p>&#32780;&nbsp;<code>a_list_to_be_sorted.sort()</code>&nbsp;&#21063;&#26159;&#30452;&#25509;&#23559;&#25490;&#24207;&#26356;&#21205;&#20102;&#65292;&#19981;&#38656;&#35201;&#26356;&#26032;&#21407;&#26412;&#21629;&#21517;&#30340;&#20018;&#21015;&#65292;&#20063;&#19981;&#26371;&#20276;&#38568;&#26377;&#22238;&#20659;&#20540;&#12290;</p><pre><code><code>primes_list = [11, 7, 5, 3, 2]
primes_list.sort()  # Call sort method of primes_list print(primes_list)  # primes_list is sorted</code></code></pre><p>&#22810;&#25976;&#24773;&#27841;&#19979;&#20989;&#25976;&#33287;&#26041;&#27861;&#26371;&#22312;&#12300;&#20197;&#22238;&#20659;&#20540;&#36664;&#20986;&#12301;&#25110;&#12300;&#30452;&#25509;&#26356;&#21205;&#29289;&#20214;&#30340;&#29376;&#24907;&#12301;&#25799;&#19968;&#65292;&#23569;&#25976;&#24773;&#27841;&#19979;&#26371;&#26377;&#20841;&#32773;&#20860;&#20855;&#30340;&#24773;&#27841;&#65292;&#20363;&#22914;&#20018;&#21015;&#26041;&#27861; <code>pop()</code> &#33021;&#22816;&#23559;&#20018;&#21015;&#26411;&#31471;&#30340;&#36039;&#26009;&#25291;&#20986;&#28858;&#22238;&#20659;&#20540;&#65292;&#20006;&#21034;&#38500;&#20018;&#21015;&#26411;&#31471;&#30340;&#36039;&#26009;&#40670;&#12290;</p><pre><code><code>primes_list = [11, 7, 5, 3, 2]
the_last_element = primes_list.pop()
print(primes_list)       # The last element was deleted print(the_last_element)  # The last element was returned</code></code></pre><p>&#36889;&#24847;&#21619;&#33879;&#35373;&#35336;&#28858;&#12300;&#20989;&#25976;&#12301;&#25110;&#32773;&#12300;&#29289;&#20214;&#30340;&#26041;&#27861;&#12301;&#20006;&#19981;&#20195;&#34920;&#24688;&#22909;&#23565;&#25033;&#12300;&#20197;&#22238;&#20659;&#20540;&#36664;&#20986;&#12301;&#25110;&#12300;&#30452;&#25509;&#26356;&#21205;&#29289;&#20214;&#29376;&#24907;&#12301;&#65292;&#32085;&#22823;&#22810;&#25976;&#30340;&#20989;&#25976;&#30906;&#23526;&#26159;&#20197;&#22238;&#20659;&#20540;&#36664;&#20986;&#65292;&#20294;&#29289;&#20214;&#30340;&#26041;&#27861;&#21063;&#21487;&#33021;&#26377;&#20197;&#22238;&#20659;&#20540;&#36664;&#20986;&#30340;&#35373;&#35336;&#12289;&#26377;&#30452;&#25509;&#26356;&#21205;&#29289;&#20214;&#29376;&#24907;&#30340;&#35373;&#35336;&#29978;&#33267;&#26159;&#29992;&#21443;&#25976;&#20358;&#27770;&#23450;&#35201;&#22238;&#20659;&#20540;&#36664;&#20986;&#25110;&#30452;&#25509;&#26356;&#21205;&#29289;&#20214;&#29376;&#24907;&#12290;&#20363;&#22914;&#36039;&#26009;&#31185;&#23416;&#27169;&#32068; Pandas &#25152;&#21109;&#36896;&#30340; <code>DataFrame</code> &#39006;&#21029;&#30340; <code>drop</code> &#26041;&#27861;&#23601;&#26159;&#25505;&#29992; <code>inplace</code> &#21443;&#25976;&#20358;&#27770;&#23450;&#12300;&#20197;&#22238;&#20659;&#20540;&#36664;&#20986;&#12301;&#25110;&#12300;&#30452;&#25509;&#26356;&#21205;&#29289;&#20214;&#29376;&#24907;&#12301;&#12290;</p><pre><code>import pandas as pd

df = pd.DataFrame()
df["order"] = list(range(1, 6))
df["prime"] = [2, 3, 5, 7, 11]
df.drop(axis=1, labels="prime")
print(df) # Column is not dropped
df.drop(axis=1, labels="prime", inplace=True)
df # Column was dropped</code></pre><h2>&#20989;&#25976;&#30340;&#20358;&#28304;</h2><p>Python &#20351;&#29992;&#32773;&#38500;&#20102;&#33021;&#22816;&#25033;&#29992;&#20839;&#24314;&#20989;&#25976;&#20197;&#22806;&#65292;&#36996;&#21487;&#20197;&#24478;&#20854;&#20182;&#19977;&#20491;&#31649;&#36947;&#21462;&#24471;&#25976;&#20540;&#35336;&#31639;&#12289;&#25991;&#23383;&#34389;&#29702;&#12289;&#36039;&#26009;&#32080;&#27083;&#25110;&#26356;&#22810;&#20854;&#20182;&#25033;&#29992;&#25152;&#38656;&#30340;&#20989;&#25976;&#65306;</p><ol><li><p>&#27161;&#28310;&#27169;&#32068;&#12290;</p></li><li><p>&#31532;&#19977;&#26041;&#27169;&#32068;&#12290;</p></li><li><p>&#33258;&#34892;&#23450;&#32681;&#12290;</p></li></ol><p>&#20677;&#26377;&#20839;&#24314;&#20989;&#25976;&#21487;&#20197;&#20379;&#25105;&#20497;&#30452;&#25509;&#20351;&#29992;&#65292;&#21478;&#22806;&#36889;&#19977;&#20491;&#31649;&#36947;&#30340;&#20989;&#25976;&#37117;&#24517;&#38920;&#22312;&#20351;&#29992;&#20043;&#21069;&#30906;&#23450;&#22909;&#22312;&#27442;&#29986;&#29983;&#20316;&#29992;&#30340;&#31684;&#30087;&#65288;&#20316;&#29992;&#22495;&#65289;&#20013;&#24050;&#32147;&#34987;&#36617;&#20837;&#25110;&#32773;&#23450;&#32681;&#12290;&#20351;&#29992;&#27161;&#28310;&#27169;&#32068;&#20197;&#21450;&#31532;&#19977;&#26041;&#27169;&#32068;&#20013;&#30340;&#20989;&#25976;&#20043;&#21069;&#65292;&#25105;&#20497;&#24517;&#38920;&#30906;&#35469;&#27169;&#32068;&#26159;&#21542;&#24050;&#32147;&#23433;&#35037;&#36617;&#20837;&#65292;&#20351;&#29992;&#33258;&#34892;&#23450;&#32681;&#30340;&#20989;&#25976;&#20043;&#21069;&#65292;&#21063;&#26159;&#24517;&#38920;&#30906;&#35469;&#35442;&#20989;&#25976;&#26159;&#21542;&#24050;&#32147;&#23436;&#25104;&#23450;&#32681;&#12290;</p><p>&#36617;&#20837;&#27169;&#32068;&#30340;&#20445;&#30041;&#23383;&#26159;&nbsp;<code>import</code>&#65292;&#20351;&#29992;&#27169;&#32068;&#30340;&#20989;&#25976;&#21063;&#38656;&#35201;&#22312;&#20854;&#21517;&#31281;&#20043;&#21069;&#35387;&#26126;&#20854;&#27169;&#32068;&#21517;&#31281;&#65292;&#20363;&#22914;&#24341;&#20837;&#27161;&#28310;&#27169;&#32068; <code>random</code>&#65292;&#28982;&#24460;&#20351;&#29992;&#20854;&#20013;&#30340; <code>randint</code> &#20989;&#25976;&#38568;&#27231;&#22312; 0 &#33287; 1 &#20043;&#38291;&#25361;&#36984;&#25972;&#25976;&#12290;</p><pre><code><code>import random 

print(type(random))
print(type(random.randint))
random_integer = random.randint(0, 1)
print(random_integer)</code></code></pre><h2>&#33258;&#34892;&#23450;&#32681;&#20989;&#25976;</h2><p>Python &#25552;&#20379;&#20102;&#19977;&#31278;&#12300;&#32068;&#32340;&#31243;&#24335;&#30908;&#12301;&#30340;&#27231;&#21046;&#20379;&#20351;&#29992;&#32773;&#23559;&#26410;&#20358;&#24819;&#35201;&#37325;&#35079;&#20351;&#29992;&#30340;&#31243;&#24335;&#30908;&#21253;&#35037;&#25104;&#23481;&#26131;&#20351;&#29992;&#12289;&#23481;&#26131;&#25844;&#20805;&#21151;&#33021;&#30340;&#24418;&#24335;&#65292;&#36889;&#19977;&#31278;&#27231;&#21046;&#26371;&#35222;&#25033;&#29992;&#35215;&#27169;&#30001;&#23567;&#21040;&#22823;&#21312;&#20998;&#28858;&#65306;</p><ol><li><p>&#33258;&#34892;&#23450;&#32681;&#20989;&#25976;&#12290;</p></li><li><p>&#33258;&#34892;&#23450;&#32681;&#39006;&#21029;&#12290;</p></li><li><p>&#33258;&#34892;&#23450;&#32681;&#27169;&#32068;&#12290;</p></li></ol><p>&#22312;&#36889;&#31687;&#25991;&#31456;&#20013;&#25105;&#20497;&#23560;&#27880;&#33258;&#34892;&#23450;&#32681;&#20989;&#25976;&#65292;&#20063;&#23601;&#26159;&#26368;&#23567;&#30340;&#32068;&#32340;&#31243;&#24335;&#30908;&#27231;&#21046;&#65292;&#22312;&#33258;&#34892;&#23450;&#32681;&#20989;&#25976;&#26178;&#20505;&#38656;&#35201;&#32771;&#24942;&#20116;&#20491;&#32068;&#25104;&#35201;&#20214;&#65306;</p><ol><li><p>&#20989;&#25976;&#21517;&#31281;&#12290;</p></li><li><p>&#36664;&#20837;&#12290;</p></li><li><p>&#21443;&#25976;&#12290;</p></li><li><p>&#20989;&#25976;&#20027;&#39636;&#12290;</p></li><li><p>&#36664;&#20986;&#12290;</p></li></ol><p>&#30475;&#20284;&#25277;&#35937;&#65292;&#19981;&#36942;&#24819;&#24819;&#24179;&#26085;&#36092;&#36023;&#29645;&#29664;&#39854;&#22902;&#33590;&#30340;&#27969;&#31243;&#65292;&#23601;&#20687;&#26159;&#20989;&#25976;&#30340;&#36939;&#20316;&#19968;&#33324;&#65306;</p><ol><li><p>&#20989;&#25976;&#21517;&#31281;&#65306;&#36092;&#36023;&#29645;&#29664;&#39854;&#22902;&#33590;&#12290;</p></li><li><p>&#36664;&#20837;&#65306;&#20013;&#26479; 35 &#20803;&#65307;&#22823;&#26479; 50 &#20803;&#12290;</p></li><li><p>&#21443;&#25976;&#65306;&#29980;&#24230;&#65288;&#28961;&#31958;&#12289;&#24494;&#31958;&#12289;&#21322;&#31958;&#12289;&#23569;&#31958;&#12289;&#20840;&#31958;&#65289;&#33287;&#20912;&#22602;&#65288;&#21435;&#20912;&#12289;&#23569;&#20912;&#12289;&#20840;&#20912;&#65289;&#12290;</p></li><li><p>&#20989;&#25976;&#20027;&#39636;&#65306;&#40670;&#39184;&#12289;&#36028;&#27161;&#31844;&#12289;&#21152;&#29645;&#29664;&#12289;&#21152;&#20912;&#22602;&#12289;&#20498;&#33590;&#12289;&#21152;&#39854;&#22902;&#19968;&#30452;&#21040;&#23553;&#21475;&#12290;</p></li><li><p>&#36664;&#20986;&#65306;&#29645;&#29664;&#39854;&#22902;&#33590;&#12290;</p></li></ol><pre><code><code>def function_name(INPUTS, PARAMETERS):
    # body of the function
    # ...
    # ...sequence of statements
    return OUTPUTS</code></code></pre><h2>&#20316;&#29992;&#22495;</h2><p>&#22312;<a href="https://datainpoint.substack.com/p/week-fifteen-control-flow-in-python">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#30340;&#27969;&#31243;&#25511;&#21046;</a>&#25105;&#20497;&#25552;&#21040;&#20102;&#31243;&#24335;&#21312;&#22602;&#65288;Code blocks&#65289;&#30340;&#35264;&#24565;&#65292;&#19981;&#35542;&#26159;&#26781;&#20214;&#21028;&#26039;&#12289;&#36852;&#22280;&#25110;&#32773;&#20363;&#22806;&#34389;&#29702;&#65292;&#37117;&#20208;&#36084;&#32302;&#25490;&#65288;Indentations&#65289;&#24314;&#31435;&#20986;&#31243;&#24335;&#21312;&#22602;&#65292;&#20006;&#20197;&#27492;&#20316;&#28858;&#25944;&#36848;&#30340;&#38468;&#23660;&#12290;&#22312;&#33258;&#34892;&#23450;&#32681;&#20989;&#25976;&#26178;&#20063;&#21516;&#27171;&#20197;&#31243;&#24335;&#21312;&#22602;&#24314;&#27083;&#20986;&#20989;&#25976;&#20027;&#39636;&#65292;&#19981;&#36942;&#26356;&#29305;&#21029;&#30340;&#26159;&#65292;&#38468;&#23660;&#26044; <code>def</code> &#25944;&#36848;&#30340;&#31243;&#24335;&#21312;&#22602;&#20855;&#26377;&#19968;&#20491;&#31281;&#28858;&#20316;&#29992;&#22495;&#65288;&#25110;&#31281;&#31684;&#30087; Scope&#65289;&#30340;&#35264;&#24565;&#65292;&#22312;&#38468;&#23660;&#26044;&#20989;&#25976;&#19979;&#30340;&#31243;&#24335;&#21312;&#22602;&#34987;&#31281;&#28858; Local scope&#65292;&#20989;&#25976;&#20197;&#22806;&#30340;&#37096;&#20998;&#21063;&#31281;&#28858; Global scope&#12290;&#22312; Local scope &#20013;&#25105;&#20497;&#21487;&#20197;&#36939;&#29992; INPUTS&#12289;PARAMETERS &#20358;&#36914;&#34892;&#36939;&#31639;&#20006;&#23459;&#21578;&#26032;&#30340;&#29289;&#20214;&#65292;&#20294;&#26159;&#36889;&#37117;&#20407;&#38480;&#26044; Local scope &#20043;&#20013;&#65292;&#19968;&#20294;&#22312; Global scope &#24847;&#22294;&#36939;&#29992;&#21069;&#36848;&#30340;&#36889;&#20123;&#29289;&#20214;&#65292;&#37117;&#26371;&#36973;&#36935;&#21040; NameError&#65292;&#24847;&#21363;&#22312; Global scope &#20013;&#36889;&#20123;&#29289;&#20214;&#12300;&#27794;&#26377;&#20316;&#29992;&#12301;&#65292;&#36889;&#20063;&#26159;&#20316;&#29992;&#22495;&#19968;&#35422;&#30340;&#30001;&#20358;&#12290;&#20363;&#22914;&#22312; Global scope &#20013;&#35430;&#22294;&#21360;&#20986;&#20219;&#20309;&#22312; Local scope &#20013;&#21487;&#20197;&#36939;&#29992;&#30340;&#29289;&#20214;&#37117;&#26371;&#36973;&#36935; NameError&#12290;</p><pre><code>def is_factor(a, b):
    modulo = a % b
    out = modulo == 0
    return out

print(is_factor(4, 2))
try:
    print(a)
    print(b)
    print(modulo)
    print(out)
except NameError:
    print("NameError occurred.")</code></pre><h2>return &#30340;&#20316;&#29992;</h2><p>&#21021;&#27425;&#23416;&#32722;&#33258;&#34892;&#23450;&#32681;&#20989;&#25976;&#22810;&#21322;&#37117;&#19981;&#29978;&#26296;&#35299; <code>return</code> &#20445;&#30041;&#23383;&#30340;&#20316;&#29992;&#65292;&#21407;&#22240;&#26159;&#20808;&#21069;&#22826;&#36942;&#38971;&#32321;&#22320;&#20351;&#29992; <code>print()</code> &#20989;&#25976;&#23559;&#25991;&#23383;&#34389;&#29702;&#12289;&#25976;&#20540;&#35336;&#31639;&#25110;&#32773;&#36039;&#26009;&#32080;&#27083;&#25805;&#20316;&#30340;&#32080;&#26524;&#39023;&#31034;&#20986;&#20358;&#65292;&#23566;&#33268;&#22312;&#33258;&#34892;&#23450;&#32681;&#20989;&#25976;&#26178;&#19981;&#32722;&#24931;&#21435;&#20351;&#29992; <code>return</code>&#12290;&#20107;&#23526;&#19978;&#65292;<code>return</code> &#20445;&#30041;&#23383;&#20855;&#26377;&#20841;&#20491;&#20316;&#29992;&#65292;&#31532;&#19968;&#20491;&#36319;&#23383;&#38754;&#19978;&#24847;&#32681;&#30456;&#21516;&#30340;&#23559;&#20989;&#25976;&#32080;&#26524;&#12300;&#36664;&#20986;&#12301;&#65292;&#20551;&#22914;&#22312;&#33258;&#34892;&#23450;&#32681;&#20989;&#25976;&#26178;&#21482;&#26377;&#23559;&#36939;&#31639;&#32080;&#26524;&#29992; <code>print()</code> &#20989;&#25976;&#39023;&#31034;&#20986;&#20358;&#65292;&#35442;&#20989;&#25976;&#23601;&#19981;&#20855;&#20633;&#33021;&#23559;&#32080;&#26524;&#20786;&#23384;&#22312;&#29289;&#20214;&#20013;&#30340;&#33021;&#21147;&#65292;&#35722;&#25104;&#21482;&#33021;&#22816;&#22312;&#20351;&#29992;&#26178;&#39023;&#31034;&#32080;&#26524;&#65292;&#21371;&#19981;&#33021;&#23559;&#32080;&#26524;&#20786;&#23384;&#36215;&#20358;&#65292;&#20363;&#22914;&#24819;&#35201;&#23559;&#21028;&#26039;&#22240;&#25976;&#30340;&#32080;&#26524;&#20786;&#23384;&#36215;&#20358;&#65292;&#21371;&#24471;&#21040;&#20102; <code>None</code>&#12290;</p><pre><code><code>def is_factor(a, b):
    modulo = a % b
    out = modulo == 0
    print(out)

function_output = is_factor(4, 2)
print(function_output)</code></code></pre><p>&#31532;&#20108;&#20491;&#26159;&#32066;&#27490;&#31243;&#24335;&#21312;&#22602;&#30340;&#22519;&#34892;&#65292;&#22312;&#20989;&#25976;&#31243;&#24335;&#21312;&#22602;&#20013;&#23531;&#22312; <code>return</code> &#20043;&#24460;&#30340;&#25152;&#26377;&#20839;&#23481;&#22312;&#20351;&#29992;&#20989;&#25976;&#30340;&#26178;&#20505;&#37117;&#19981;&#26371;&#26377;&#20219;&#20309;&#20316;&#29992;&#12290;</p><pre><code>def is_factor(a, b):
    modulo = a % b
    out = modulo == 0
    return out
    print(out)    # will not be printed
    print(modulo) # will not be printed
    print(a)      # will not be printed
    print(b)      # will not be printed

function_output = is_factor(4, 2)
print(function_output)</code></pre><h2>&#36664;&#20837;&#33287;&#36664;&#20986;&#30340;&#23565;&#25033;&#38364;&#20418;</h2><p>&#33258;&#34892;&#23450;&#32681;&#20989;&#25976;&#30340;&#37325;&#40670;&#22312;&#26044;&#35215;&#21123;&#36664;&#20837;&#33287;&#36664;&#20986;&#30340;&#23565;&#25033;&#38364;&#20418;&#65292;&#22914;&#21516;&#22312;&#25976;&#23416;&#35506;&#20013;&#23416;&#36942;&#30340;&#12300;&#20989;&#25976;&#26144;&#23556;&#38364;&#20418;&#12301;&#65292;&#21482;&#35201;&#37328;&#28165;&#20102;&#33258;&#34892;&#23450;&#32681;&#20989;&#25976;&#37341;&#23565;&#36664;&#20837;&#33287;&#36664;&#20986;&#30340;&#35373;&#35336;&#27231;&#21046;&#65292;&#21097;&#19979;&#30340;&#20219;&#21209;&#23601;&#20677;&#26159;&#23559;&#31243;&#24335;&#21312;&#22602;&#30340;&#20989;&#25976;&#20027;&#39636;&#23436;&#25104;&#32780;&#24050;&#12290;</p><p>&#24478;&#36664;&#20837;&#38283;&#22987;&#65292;&#20989;&#25976;&#21487;&#20197;&#25509;&#21463;&#27794;&#26377;&#36664;&#20837;&#33287;&#21443;&#25976;&#30340;&#35373;&#35336;&#65292;&#22312;&#23567;&#25324;&#34399;&#20013;&#30041;&#31354;&#21363;&#21487;&#12290;</p><pre><code>def hello_world():
    return "Hello, World!"

print(hello_world())</code></pre><p>&#20989;&#25976;&#30070;&#28982;&#21487;&#20197;&#25509;&#21463;&#26377;&#36664;&#20837;&#33287;&#21443;&#25976;&#30340;&#35373;&#35336;&#65292;&#22909;&#30340;&#20989;&#25976;&#35373;&#35336;&#26371;&#22312;&#21443;&#25976;&#32102;&#20104;&#21512;&#36969;&#30340;&#38928;&#35373;&#20540;&#12290;</p><pre><code>def hello_someone(someone="World"):
    return f"Hello, {someone}!"

print(hello_someone())
print(hello_someone(someone="Function"))</code></pre><p>&#35373;&#35336;&#35201;&#25509;&#21463;&#22810;&#20491;&#36664;&#20837;&#20540;&#30340;&#20989;&#25976;&#26178;&#65292;&#21487;&#20197;&#29992;&#36039;&#26009;&#32080;&#27083;&#23481;&#32013;&#22810;&#20491;&#36664;&#20837;&#36039;&#26009;&#12290;</p><pre><code>def square_multiple_integers(x):
    out = []
    for elem in x:
        out.append(elem**2)
    return out

print(square_multiple_integers([2, 3]))
print(square_multiple_integers([2, 3, 5]))</code></pre><p>&#22914;&#26524;&#24076;&#26395;&#22810;&#20491;&#36664;&#20837;&#20540;&#20998;&#21029;&#20197;&#21443;&#25976;&#20659;&#20837;&#32780;&#36039;&#26009;&#32080;&#27083;&#65292;&#21487;&#20197;&#36939;&#29992; Python &#33258;&#34892;&#23450;&#32681;&#20989;&#25976;&#30340;&#29305;&#27530;&#35373;&#35336;&#65306;&#24392;&#24615;&#21443;&#25976;&#65288;Flexible arguments&#65289;&#65292;&#22312;&#23567;&#25324;&#34399;&#20013;&#32102;&#20104; <code>*args</code> &#23601;&#33021;&#22816;&#22312; Local scope &#20013;&#20197; <code>tuple</code> &#34389;&#29702; <code>args</code>&#12290;</p><pre><code>def square_multiple_integers(*args):
    print(type(args))
    out = []
    for elem in args:
        out.append(elem**2)
    return out

print(square_multiple_integers(2, 3))
print(square_multiple_integers(2, 3, 5))</code></pre><p>&#20877;&#20358;&#26159;&#36664;&#20986;&#65292;&#21363;&#20415;&#32085;&#22823;&#22810;&#25976;&#30340;&#20989;&#25976;&#37117;&#20855;&#26377;&#22238;&#20659;&#20540;&#65292;&#20294;&#20063;&#19981;&#20195;&#34920;&#20989;&#25976;&#38750;&#20855;&#20633; return &#19981;&#21487;&#65292;&#22914;&#26524;&#26159;&#36889;&#27171;&#30340;&#24773;&#27841;&#25105;&#20497;&#26371;&#24471;&#21040; None &#28858;&#20989;&#25976;&#30340;&#22238;&#20659;&#20540;&#12290;</p><pre><code>def hello_world():
    out = "Hello, World!"

function_output = hello_world()
print(type(function_output))</code></pre><p>&#22810;&#20491;&#36664;&#20986;&#30340;&#34389;&#29702;&#38928;&#35373;&#26159;&#20197; <code>tuple</code> <code>&#22238;&#20659;</code>&#65292;&#20134;&#21487;&#20197;<code>&#25645;&#37197;</code> Python &#30340; Unpack &#29305;&#24615;&#29992;&#22810;&#20491;&#29289;&#20214;&#21435;&#20786;&#23384;&#12290;</p><pre><code>def square_two_integers(a, b):
    out_a = a**2
    out_b = b**2
    return out_a, out_b

function_output_as_tuple = square_two_integers(3, 4)
func_out_a, func_out_b = square_two_integers(3, 4)
print(type(function_output_as_tuple))
print(func_out_a)
print(func_out_b)</code></pre><p>&#22810;&#20491;&#36664;&#20986;&#30340;&#34389;&#29702;&#30456;&#36611;&#36664;&#20837;&#21934;&#32020;&#35377;&#22810;&#65292;&#23601;&#26159;&#25505;&#29992;&#36969;&#30070;&#30340;&#36039;&#26009;&#32080;&#27083;&#20786;&#23384;&#12290;</p><pre><code><code>def square_two_integers(a, b):
    out = {
        "a": a**2,
        "b": b**2
    }
    return out
function_output_as_dict = square_two_integers(3, 4)
print(function_output_as_dict)</code></code></pre><p>&#22312;&#35469;&#35672;&#20102;&#20989;&#25976;&#30340;&#21508;&#31278;&#30473;&#30473;&#35282;&#35282;&#20043;&#24460;&#65292;&#31532;&#21313;&#20845;&#36913;&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#30340;&#20989;&#25976;&#20358;&#21040;&#23614;&#32882;&#65292;&#24076;&#26395;&#24744;&#20063;&#21644;&#25105;&#19968;&#27171;&#26399;&#24453;&#19979;&#19968;&#31687;&#25991;&#31456;&#12290;</p><h2>&#24310;&#20280;&#38321;&#35712;</h2><ul><li><p><a href="https://docs.python.org/3/library/functions.html">https://docs.python.org/3/library/functions.html</a></p></li></ul><h2>&#35336;&#30059;&#23416;&#21729;&#23560;&#21312;</h2><p>&#32004;&#32173;&#23433;&#35336;&#30059;&#23416;&#21729;&#21487;&#20197;&#40670;&#36984; nbgitpuller &#36899;&#32080;&#23559;&#26412;&#31687;&#25991;&#31456;&#23436;&#25972;&#30340; Jupyter Notebook &#35079;&#35069;&#21040;&#33258;&#24049;&#30340; JupyterHub &#20043;&#20013;&#65306;</p><p><a href="https://lab.datainpoint.com/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fdatainpoint%2Fweek-sixteen-functions-in-python.git&amp;urlpath=tree%2Fweek-sixteen-functions-in-python.git%2Fnotebook.ipynb&amp;branch=main">nbgitpuller &#36899;&#32080;</a></p><p>&#20282;&#26381;&#22120;&#36984;&#38917;&#36984;&#25799;&#38928;&#35373;&#30340;&#12300;Data science environment&#65306;&#23416;&#32722; Python&#12289;R &#33287; Julia &#30340;&#36039;&#26009;&#31185;&#23416;&#29872;&#22659;&#12301;&#23601;&#21487;&#20197;&#38918;&#21033;&#36939;&#20316;&#25991;&#31456;&#20013;&#30340;&#31684;&#20363;&#31243;&#24335;&#12290;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HMwv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HMwv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 424w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 848w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1272w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!HMwv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png" width="1456" height="964" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:964,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:137396,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!HMwv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 424w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 848w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1272w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#36984;&#25799;&#12300;Data science environment&#65306;&#23416;&#32722; Python&#12289;R &#33287; Julia &#30340;&#36039;&#26009;&#31185;&#23416;&#29872;&#22659;&#12301;</figcaption></figure></div><div><hr></div><p>&#23565;&#26044;&#36889;&#31687;&#25991;&#31456;&#26377;&#20160;&#40636;&#24819;&#27861;&#21602;&#65311;&#21916;&#27489;&#128571;&#12289;&#30041;&#35328;&#128587;&#8205;&#9794;&#65039;&#25110;&#32773;&#20998;&#20139;&#128588;</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://datainpoint.substack.com/p/week-sixteen-functions-in-python/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://datainpoint.substack.com/p/week-sixteen-functions-in-python/comments"><span>Leave a comment</span></a></p>]]></content:encoded></item><item><title><![CDATA[約維安計畫：Python 的流程控制]]></title><description><![CDATA[&#31532;&#21313;&#20116;&#36913;&#12290;]]></description><link>https://datainpoint.substack.com/p/week-fifteen-control-flow-in-python</link><guid isPermaLink="false">https://datainpoint.substack.com/p/week-fifteen-control-flow-in-python</guid><dc:creator><![CDATA[Yao-Jen Kuo]]></dc:creator><pubDate>Wed, 25 Aug 2021 08:16:35 GMT</pubDate><enclosure url="https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/3798908f-1118-4c62-916f-444e7b468401_150x135.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_fHi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe02f123b-0f9a-466c-84b7-aebf1e8047f7_150x135.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_fHi!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe02f123b-0f9a-466c-84b7-aebf1e8047f7_150x135.gif 424w, https://substackcdn.com/image/fetch/$s_!_fHi!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe02f123b-0f9a-466c-84b7-aebf1e8047f7_150x135.gif 848w, https://substackcdn.com/image/fetch/$s_!_fHi!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe02f123b-0f9a-466c-84b7-aebf1e8047f7_150x135.gif 1272w, https://substackcdn.com/image/fetch/$s_!_fHi!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe02f123b-0f9a-466c-84b7-aebf1e8047f7_150x135.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_fHi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe02f123b-0f9a-466c-84b7-aebf1e8047f7_150x135.gif" width="320" height="288" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/e02f123b-0f9a-466c-84b7-aebf1e8047f7_150x135.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:135,&quot;width&quot;:150,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:502042,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!_fHi!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe02f123b-0f9a-466c-84b7-aebf1e8047f7_150x135.gif 424w, https://substackcdn.com/image/fetch/$s_!_fHi!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe02f123b-0f9a-466c-84b7-aebf1e8047f7_150x135.gif 848w, https://substackcdn.com/image/fetch/$s_!_fHi!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe02f123b-0f9a-466c-84b7-aebf1e8047f7_150x135.gif 1272w, https://substackcdn.com/image/fetch/$s_!_fHi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe02f123b-0f9a-466c-84b7-aebf1e8047f7_150x135.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a><figcaption class="image-caption">&#20358;&#28304;&#65306;giphy.com</figcaption></figure></div><h2>&#20160;&#40636;&#26159;&#27969;&#31243;&#25511;&#21046;</h2><p>&#22810;&#25976;&#31243;&#24335;&#35486;&#35328;&#37117;&#26371;&#24478;&#31243;&#24335;&#30908;&#30340;&#31532;&#19968;&#21015;&#38283;&#22987;&#25353;&#29031;&#21015;&#65288;Row-wise&#65289;&#30340;&#38918;&#24207;&#24448;&#19979;&#35712;&#21462;&#20006;&#19988;&#22519;&#34892;&#65292;&#20294;&#26159;&#22312;&#26576;&#20123;&#24773;&#27841;&#19979;&#65292;&#25105;&#20497;&#26371;&#24076;&#26395;&#33021;&#22312;&#26576;&#20123;&#31243;&#24335;&#30908;&#21487;&#20197;&#20381;&#29031;&#38656;&#27714;&#19981;&#22519;&#34892;&#12289;&#22519;&#34892;&#25110;&#32773;&#22519;&#34892;&#22810;&#27425;&#65292;&#36889;&#26178;&#23601;&#21487;&#20197;&#36879;&#36942;&#27969;&#31243;&#25511;&#21046;&#30340;&#27231;&#21046;&#20358;&#28415;&#36275;&#36889;&#20123;&#24773;&#27841;&#12290;</p><p>&#27969;&#31243;&#25511;&#21046;&#25351;&#30340;&#26159;&#22312;&#31243;&#24335;&#22519;&#34892;&#26178;&#65292;&#33021;&#22816;&#20381;&#36084;&#26781;&#20214;&#20358;&#27770;&#23450;&#31243;&#24335;&#21312;&#22602;&#65288;Code blocks&#65289;&#20013;&#30340;&#25351;&#20196;&#12289;&#25944;&#36848;&#25110;&#32773;&#20989;&#25976;&#21628;&#21483;&#30340;&#22519;&#34892;&#27425;&#25976;&#65292;&#22312;&#26781;&#20214;&#28858;&#24067;&#26519; <code>False</code> &#30340;&#26178;&#20505;&#65292;&#31243;&#24335;&#21312;&#22602;&#20013;&#30340;&#31243;&#24335;&#30908;&#22519;&#34892;&#27425;&#25976;&#28858; 0&#65288;&#19981;&#22519;&#34892;&#65289;&#65307;&#22312;&#26781;&#20214;&#28858;&#24067;&#26519; <code>True</code> &#30340;&#26178;&#20505;&#65292;&#31243;&#24335;&#21312;&#22602;&#20013;&#30340;&#31243;&#24335;&#30908;&#22519;&#34892;&#27425;&#25976;&#22823;&#26044;&#31561;&#26044; 1&#12290;&#20855;&#39636;&#20358;&#35498;&#65292;&#27969;&#31243;&#25511;&#21046;&#26159;&#19968;&#31278;&#27231;&#21046;&#65292;&#36889;&#20491;&#27231;&#21046;&#33021;&#35731;&#19968;&#27573;&#25351;&#20196;&#22312;&#26576;&#20123;&#24773;&#27841;&#19979;&#19981;&#34987;&#22519;&#34892;&#12289;&#22312;&#26576;&#20123;&#24773;&#27841;&#19979;&#34987;&#22519;&#34892;&#19968;&#27425;&#25110;&#32773;&#22312;&#26576;&#20123;&#24773;&#27841;&#19979;&#34987;&#37325;&#35079;&#22519;&#34892;&#65292;Python &#23526;&#29694;&#27969;&#31243;&#25511;&#21046;&#26377;&#19977;&#31278;&#26041;&#24335;&#65306;</p><ol><li><p>&#26781;&#20214;&#21028;&#26039;&#12290;</p></li><li><p>&#36852;&#22280;&#12290;</p></li><li><p>&#20363;&#22806;&#34389;&#29702;&#12290;</p></li></ol><p>&#20854;&#20013;&#65292;&#26781;&#20214;&#21028;&#26039;&#33021;&#22816;&#20351;&#29992; <code>if-elif-else</code> &#25944;&#36848;&#33287;&#24067;&#26519;&#23436;&#25104;&#65307;&#36852;&#22280;&#21063;&#26377;&#20841;&#31278;&#36984;&#25799;&#65292;&#19968;&#26159;&#20351;&#29992; <code>while</code> &#25944;&#36848;&#33287;&#24067;&#26519;&#65292;&#20108;&#26159;&#20351;&#29992; <code>for</code> &#25944;&#36848;&#33287;&#21487;&#36208;&#35370;&#29289;&#20214;&#65288;Iterables&#65289;&#65307;&#20363;&#22806;&#34389;&#29702;&#33021;&#22816;&#20351;&#29992; <code>try-except</code> &#25944;&#36848;&#33287;&#37679;&#35492;&#31278;&#39006;&#23436;&#25104;&#12290;</p><h2>&#20160;&#40636;&#26159;&#21312;&#22602;</h2><p>&#21312;&#22602;&#65288;Code blocks&#65289;&#25351;&#30340;&#26159;&#23559;&#19968;&#31995;&#21015;&#30456;&#38364;&#30340;&#25944;&#36848;&#38598;&#21512;&#22312;&#19968;&#36215;&#30340;&#31243;&#24335;&#30908;&#32080;&#27083;&#65292;&#22312;&#22810;&#25976;&#30340;&#31243;&#24335;&#35486;&#35328;&#20013;&#65292;&#21312;&#22602;&#20351;&#29992;&#19968;&#23565;&#22823;&#25324;&#34399;&#65288;A curly-brace pair&#65289;&#23559;&#25944;&#36848;&#21253;&#35037;&#22312;&#35041;&#38754;&#24418;&#25104;&#21312;&#22602;&#12290;&#20294;&#26159;&#65292;&#22312; Python &#20013;&#24314;&#31435;&#21312;&#22602;&#36319;&#22810;&#25976;&#30340;&#31243;&#24335;&#35486;&#35328;&#25130;&#28982;&#19981;&#21516;&#65292;Python &#20351;&#29992;&#32302;&#25490;&#65288;Indentations&#65289;&#32780;&#38750;&#19968;&#23565;&#22823;&#25324;&#34399;&#20358;&#23559;&#25944;&#36848;&#21253;&#35037;&#28858;&#21312;&#22602;&#65292;&#22312;&#21069;&#36848;&#19977;&#31278;&#39006;&#22411;&#30340;&#27969;&#31243;&#25511;&#21046;&#20013;&#65292;&#37117;&#26371;&#21033;&#29992;&#21312;&#22602;&#23559;&#25944;&#36848;&#20381;&#38468;&#32102;&#26781;&#20214;&#21028;&#26039;&#12289;&#36852;&#22280;&#33287;&#20363;&#22806;&#34389;&#29702;&#65292;&#22914;&#27492;&#19968;&#20358;&#23601;&#33021;&#22816;&#22312;&#26576;&#20123;&#24773;&#27841;&#19979;&#35731;&#21312;&#22602;&#20013;&#30340;&#31243;&#24335;&#19981;&#34987;&#22519;&#34892;&#12289;&#22519;&#34892;&#20677;&#19968;&#27425;&#25110;&#22519;&#34892;&#29305;&#23450;&#27425;&#25976;&#12290;</p><h2>&#26781;&#20214;&#21028;&#26039;</h2><p>&#26781;&#20214;&#21028;&#26039;&#26159;&#20381;&#25351;&#23450;&#35722;&#25976;&#25110;&#32773;&#36939;&#31639;&#30340;&#24067;&#26519;&#20540;&#28858;&#30495;&#25110;&#20551;&#26178;&#65292;&#20358;&#27770;&#23450;&#26159;&#21542;&#22519;&#34892;&#19968;&#27573;&#20301;&#26044;&#26576;&#21312;&#22602;&#20839;&#30340;&#31243;&#24335;&#65292;&#36879;&#36942;&nbsp;<code>if-elif-else</code>&nbsp;&#25944;&#36848;&#21487;&#20197;&#26681;&#25818;&#25351;&#23450;&#26781;&#20214;&#26159;&#21542;&#25104;&#31435;&#65292;&#27770;&#23450;&#24460;&#32396;&#35201;&#22519;&#34892;&#30340;&#31243;&#24335;&#65292;&#20063;&#21487;&#20197;&#32068;&#21512;&#22810;&#20491;&nbsp;<code>if-elif-else</code>&nbsp;&#25944;&#36848;&#36914;&#34892;&#26356;&#35079;&#38620;&#30340;&#26781;&#20214;&#21028;&#26039;&#12290;</p><p>&#25105;&#20497;&#20351;&#29992;&#20445;&#30041;&#23383;&nbsp;<code>if</code>&nbsp;&#25645;&#37197;&#19968;&#20491;&#26781;&#20214;&#65288;&#20043;&#24460;&#25509;&#19968;&#20491;&#20882;&#34399;&nbsp;<code>:</code>&#65289;&#23601;&#33021;&#22816;&#24314;&#31435;&#19968;&#20491; <code>if</code> &#25944;&#36848;&#65292;<code>if</code> &#25944;&#36848;&#33021;&#22816;&#35731;&#21312;&#22602;&#30340;&#22519;&#34892;&#33287;&#21542;&#20381;&#36084;&#26781;&#20214;&#30340;&#24067;&#26519;&#20540;&#65292;&#22914;&#26524;&#26781;&#20214;&#28858;&nbsp;<code>True</code>&nbsp;&#21063;&#22519;&#34892;&#20381;&#38468;&#20854;&#32302;&#25490;&#19979;&#30340;&#31243;&#24335;&#21312;&#22602;&#65307;&#33509;&#26781;&#20214;&#28858;&nbsp;<code>False</code>&nbsp;&#21063;&#19981;&#22519;&#34892;&#20381;&#38468;&#20854;&#32302;&#25490;&#19979;&#30340;&#31243;&#24335;&#21312;&#22602;&#12290;</p><pre><code><code>if CONDITION:
    # code block attached to if statement</code></code></pre><p><code>CONDITION</code> &#21487;&#20197;&#36879;&#36942;&#38364;&#20418;&#36939;&#31639;&#31526;&#25110;&#32773;&#37007;&#36655;&#36939;&#31639;&#31526;&#29983;&#25104;&#65292;&#20363;&#22914;&#21028;&#26039;&#36664;&#20837;&#25972;&#25976;&#26159;&#21542;&#28858;&#27491;&#12290;</p><pre><code>def is_positive(x):
    if x &gt;= 0:
        return f"{x} is positive."
    if x &lt; 0:
        return f"{x} is negative."

print(is_positive(0))
print(is_positive(-1))</code></pre><p>&#25105;&#20497;&#20351;&#29992;&#20445;&#30041;&#23383;&nbsp;<code>if</code>&nbsp;&#33287; <code>elif</code>&nbsp;&#25645;&#37197;&#21508;&#33258;&#30340;&#26781;&#20214;&#24314;&#31435;&#19968;&#20491; <code>if-elif</code> &#25944;&#36848;&#65292;&#22914;&#26524;&nbsp;<code>if</code>&nbsp;&#24460;&#38754;&#30340;&#26781;&#20214;&#28858;&nbsp;<code>True</code>&nbsp;&#21063;&#22519;&#34892;&#20381;&#38468;&#20854;&#32302;&#25490;&#19979;&#30340;&#31243;&#24335;&#21312;&#22602;&#65307;&#33509;&nbsp;<code>if</code>&nbsp;&#24460;&#38754;&#30340;&#26781;&#20214;&#28858;&nbsp;<code>False</code>&nbsp;&#21063;&#36339;&#36942;&#35442;&#21312;&#22602;&#25913;&#28858;&#27298;&#35222;&nbsp;<code>elif</code>&nbsp;&#24460;&#38754;&#30340;&#26781;&#20214;&#65292;&#22914;&#26524;&#26159;&nbsp;<code>True</code>&nbsp;&#23601;&#22519;&#34892;&#20381;&#38468;&#20854;&#32302;&#25490;&#19979;&#30340;&#31243;&#24335;&#21312;&#22602;&#65307;&#33509;&nbsp;<code>elif</code>&nbsp;&#24460;&#38754;&#30340;&#26781;&#20214;&#28858;&nbsp;<code>False</code>&nbsp;&#21063;&#36339;&#36942;&#35442;&#21312;&#22602;&#65292;&#20854;&#20013; <code>elif</code> &#26159; else if &#30340;&#31777;&#23531;&#12290;</p><pre><code>if CONDITION:
    # code block attached to if statement
elif CONDITION:
    # code block attached to elif statement</code></pre><p><code>CONDITION</code> &#21487;&#20197;&#36879;&#36942;&#38364;&#20418;&#36939;&#31639;&#31526;&#25110;&#32773;&#37007;&#36655;&#36939;&#31639;&#31526;&#29983;&#25104;&#65292;&#20363;&#22914;&#21028;&#26039;&#36664;&#20837;&#25972;&#25976;&#26159;&#21542;&#28858;&#27491;&#12290;</p><pre><code>def is_positive(x):
    if x &gt;= 0:
        return f"{x} is positive."
    elif x &lt; 0:
        return f"{x} is negative."

print(is_positive(0))
print(is_positive(-1))</code></pre><p>&#25105;&#20497;&#20351;&#29992;&#20445;&#30041;&#23383;&nbsp;<code>if</code>&nbsp;&#12289;<code>else</code>&nbsp;&#25645;&#37197;&#19968;&#20491;&#26781;&#20214;&#24314;&#31435;&#19968;&#20491; <code>if-else</code> &#25944;&#36848;&#65292;&#22914;&#26524;&nbsp;<code>if</code>&nbsp;&#24460;&#38754;&#30340;&#26781;&#20214;&#28858;&nbsp;<code>True</code>&nbsp;&#21063;&#22519;&#34892;&#20381;&#38468;&#20854;&#32302;&#25490;&#19979;&#30340;&#31243;&#24335;&#21312;&#22602;&#65307;&#33509;&nbsp;<code>if</code>&nbsp;&#24460;&#38754;&#30340;&#26781;&#20214;&#28858;&nbsp;<code>False</code>&nbsp;&#21063;&#36339;&#36942;&#35442;&#21312;&#22602;&#25913;&#28858;&#22519;&#34892;&#20381;&#38468;&nbsp;<code>else</code>&nbsp;&#32302;&#25490;&#19979;&#30340;&#31243;&#24335;&#21312;&#22602;&#12290;</p><pre><code><code>if CONDITION:
    # code block attached to if statement
else:
    # code block attached to else statement</code></code></pre><p><code>CONDITION</code> &#21487;&#20197;&#36879;&#36942;&#38364;&#20418;&#36939;&#31639;&#31526;&#25110;&#32773;&#37007;&#36655;&#36939;&#31639;&#31526;&#29983;&#25104;&#65292;&#20363;&#22914;&#21028;&#26039;&#36664;&#20837;&#25972;&#25976;&#26159;&#21542;&#28858;&#27491;&#12290;</p><pre><code>def is_positive(x):
    if x &gt;= 0:
        return f"{x} is positive."
    else:
        return f"{x} is negative."

print(is_positive(0))
print(is_positive(-1))</code></pre><p>&#22312;&#21069;&#38754;&#30340;&#20363;&#23376;&#20013;&#65292;&#25105;&#20497;&#21487;&#20197;&#30475;&#21040;&#21516;&#27171;&#19968;&#20491;&#12300;&#21028;&#26039;&#36664;&#20837;&#25972;&#25976;&#26159;&#21542;&#28858;&#27491;&#12301;&#30340;&#20989;&#25976;&#65292;&#21487;&#20197;&#29992;&#19981;&#21516;&#30340;&#26781;&#20214;&#21028;&#26039;&#25944;&#36848;&#20358;&#23526;&#20316;&#65292;&#37027;&#40636;&#22312;&#25033;&#29992;&#24773;&#22659;&#19978;&#65292;&#35442;&#22914;&#20309;&#21312;&#21029;&#33287;&#25505;&#29992;&#65311;&#31777;&#21934;&#20358;&#35498;&#65292;&#25105;&#20497;&#21487;&#20197;&#34249;&#30001;&#21028;&#26039; <code>CONDITION</code> &#26159;&#21542;&#20114;&#26021;&#65288;Mutually exclusive&#65289;&#20358;&#27770;&#23450;&#12290;&#36889;&#20491;&#35498;&#27861;&#26159;&#20381;&#25818; <code>if</code> &#25944;&#36848;&#12289;<code>if-elif</code> &#33287; <code>if-else</code> &#25944;&#36848;&#30340;&#20027;&#35201;&#24046;&#21029;&#65292;&#30001;&#26044; <code>if-elif</code> &#33287; <code>if-else</code> &#25944;&#36848;&#30340;&#26781;&#20214;&#21028;&#26039;&#26159;&#26377;&#20808;&#24460;&#38918;&#24207;&#30340;&#65292;&#30070;&#21069;&#38754; <code>if</code> &#25944;&#36848;&#24471;&#21040;&#20102;&#24067;&#26519;&#20540; <code>True</code>&#65292;&#24847;&#21619;&#33879;&#24460;&#32396;&#30340; <code>elif</code> &#25110; <code>else</code> &#25944;&#36848;&#23601;&#28961;&#38364;&#32202;&#35201;&#20102;&#12290;&#31777;&#21934;&#20358;&#35498;&#65292;&#20551;&#22914;&#26781;&#20214;&#24444;&#27492;&#20043;&#38291;&#26159;&#20114;&#26021;&#30340;&#65292;&#26781;&#20214;&#21028;&#26039;&#24590;&#40636;&#23531;&#22823;&#27010;&#37117;&#27794;&#26377;&#21839;&#38988;&#65307;&#20294;&#21453;&#36942;&#20358;&#35498;&#65292;&#20551;&#22914;&#26781;&#20214;&#24444;&#27492;&#20043;&#38291;&#26159;&#12300;&#38750;&#20114;&#26021;&#12301;&#30340;&#35441;&#65292;&#21028;&#26039;&#30340;&#38918;&#24207;&#20197;&#21450; <code>if</code> &#25944;&#36848;&#12289;<code>if-elif</code> &#33287; <code>if-else</code> &#25944;&#36848;&#23601;&#26371;&#38656;&#35201;&#35641;&#24910;&#22320;&#36984;&#25799;&#12290;&#33289;&#20363;&#20358;&#35498;&#65292;&#25105;&#20497;&#20381;&#25818; <a href="https://en.wikipedia.org/wiki/Body_mass_index">https://en.wikipedia.org/wiki/Body_mass_index</a> &#23531;&#20316;&#19968;&#20491;&#20989;&#25976; <code>get_bmi_desc()</code> &#21487;&#20197;&#26681;&#25818;&#36664;&#20837;&#30340; BMI &#25976;&#20540;&#65292;&#32102;&#20104;&#36942;&#36629;&#12289;&#27491;&#24120;&#12289;&#36942;&#37325;&#25110;&#32933;&#32982;&#30340;&#25991;&#23383;&#36664;&#20986;&#65292;&#23559;&#22235;&#20491;&#26781;&#20214;&#23531;&#25104;&#20114;&#26021;&#30340;&#26684;&#24335;&#65306;</p><ol><li><p>&#36942;&#36629;&#65306;BMI &lt; 18.5&#12290;</p></li><li><p>&#27491;&#24120;&#65306;BMI &gt;= 18.5 and BMI &lt; 25&#12290;</p></li><li><p>&#36942;&#37325;&#65306;BMI &gt;= 25 and BMI &lt; 30&#12290;</p></li><li><p>&#32933;&#32982;&#65306;BMI &gt;= 30&#12290;</p></li></ol><p>&#22312;&#26781;&#20214;&#20114;&#26021;&#30340;&#29376;&#27841;&#19979;&#65292;&#24590;&#40636;&#23531;&#22823;&#27010;&#37117;&#27794;&#26377;&#21839;&#38988;&#12290;</p><pre><code>def get_bmi_desc(bmi):
    if bmi &lt; 18.5:
        bmi_desc = "&#36942;&#36629;"
    elif bmi &gt;= 30:
        bmi_desc = "&#32933;&#32982;"
    elif bmi &gt;= 25 and bmi &lt; 30:
        bmi_desc = "&#36942;&#37325;"
    elif bmi &gt;= 18.5 and bmi &lt; 25:
        bmi_desc = "&#27491;&#24120;"
    return bmi_desc

print(get_bmi_desc(17))
print(get_bmi_desc(23))
print(get_bmi_desc(29))
print(get_bmi_desc(31))</code></pre><p>&#20294;&#36889;&#19981;&#34920;&#31034;&#26781;&#20214;&#21028;&#26039;&#23601;&#24517;&#38920;&#23559;&#26781;&#20214;&#37117;&#23531;&#25104;&#20114;&#26021;&#25165;&#21487;&#20197;&#65292;&#22312;&#36969;&#30070;&#38918;&#24207;&#33287;&#25944;&#36848;&#23433;&#25490;&#19979;&#65292;&#21363;&#20351;&#38750;&#20114;&#26021;&#20063;&#33021;&#36948;&#21040;&#27491;&#30906;&#21028;&#26039;&#32080;&#26524;&#12290;</p><pre><code>def get_bmi_desc(bmi):
    if bmi &gt;= 30:
        bmi_desc = "&#32933;&#32982;"
    elif bmi &gt;= 25:
        bmi_desc = "&#36942;&#37325;"
    elif bmi &gt;= 18.5:
        bmi_desc = "&#27491;&#24120;"
    else:
        bmi_desc = "&#36942;&#36629;"
    return bmi_desc

print(get_bmi_desc(17))
print(get_bmi_desc(23))
print(get_bmi_desc(29))
print(get_bmi_desc(31))</code></pre><h2>&#36852;&#22280;</h2><p>&#36852;&#22280;&#26159;&#24120;&#35211;&#30340;&#27969;&#31243;&#25511;&#21046;&#20043;&#19968;&#65292;&#36889;&#26159;&#19968;&#31278;&#22312;&#21312;&#22602;&#20013;&#21482;&#20986;&#29694;&#19968;&#27425;&#12289;&#20294;&#21371;&#21487;&#33021;&#34987;&#36899;&#32396;&#22519;&#34892;&#22810;&#27425;&#30340;&#31243;&#24335;&#30908;&#32080;&#27083;&#65292;&#21312;&#22602;&#20013;&#30340;&#31243;&#24335;&#30908;&#26371;&#22519;&#34892;&#29305;&#23450;&#30340;&#27425;&#25976;&#12289;&#22519;&#34892;&#21040;&#29305;&#23450;&#26781;&#20214;&#25104;&#31435;&#26178;&#32080;&#26463;&#25110;&#32773;&#36208;&#35370;&#36039;&#26009;&#32080;&#27083;&#20013;&#30340;&#25152;&#26377;&#20839;&#23481;&#65292;&#33287;&#20018;&#21015;&#20999;&#21106;&#30340;&#35486;&#27861;&#27010;&#24565;&#30456;&#20284;&#65292;&#36852;&#22280;&#20063;&#33021;&#22816;&#29992;&#38283;&#22987;&#12289;&#32080;&#26463;&#33287;&#38291;&#38548;&#19977;&#20491;&#35201;&#32032;&#25551;&#36848;&#12290;</p><ul><li><p>start&#65306;&#36852;&#22280;&#30340;&#38283;&#22987;&#12290;</p></li><li><p>stop&#65306;&#36852;&#22280;&#30340;&#32080;&#26463;&#12290;</p></li><li><p>step&#65306;&#36852;&#22280;&#24478;&#36215;&#22987;&#21069;&#24448;&#32066;&#27490;&#30340;&#26041;&#27861;&#12290;</p></li></ul><p>&#25105;&#20497;&#21487;&#20197;&#20351;&#29992;&#20445;&#30041;&#23383; <code>while</code>&nbsp;&#33287;&#26781;&#20214;&#24314;&#31435;&#19968;&#20491; <code>while</code> &#36852;&#22280;&#21312;&#22602;&#65292;&#30070;&#26781;&#20214;&#28858;&nbsp;<code>True</code>&nbsp;&#37325;&#35079;&#22519;&#34892;&#20381;&#38468;&#20854;&#32302;&#25490;&#19979;&#30340;&#31243;&#24335;&#21312;&#22602;&#65292;&#25551;&#36848;&#36852;&#22280;&#30340;&nbsp;step&nbsp;&#24120;&#29992;&#35079;&#21512;&#36939;&#31639;&#31526;&#65288;Compound operators&#65289;&#65292;&#20363;&#22914; <code>i += step</code> &#23601;&#31561;&#21516;&#26044; <code>i = i + step</code>&#12290;</p><pre><code>i = 0 # start
while CONDITION: # stop
    # code block attached to while statement
    i += step</code></pre><p><code>CONDITION</code> &#21487;&#20197;&#36879;&#36942;&#38364;&#20418;&#36939;&#31639;&#31526;&#25110;&#32773;&#37007;&#36655;&#36939;&#31639;&#31526;&#29983;&#25104;&#65292;&#20363;&#22914;&#21360;&#20986;&#21069; &#8;n &#20491;&#22855;&#25976;&#12290;</p><pre><code>def print_first_n_odds(n):
    i = 1
    odds = []
    while len(odds) &lt; n:
        print(i)
        odds.append(i)
        i += 2

print_first_n_odds(5)</code></pre><p>&#25105;&#20497;&#21487;&#20197;&#20351;&#29992;&#20445;&#30041;&#23383; <code>for</code> &#33287;&#21487;&#36208;&#35370;&#29289;&#20214;&#65288;Iterables&#65289;&#24314;&#31435;&#19968;&#20491; <code>for</code> &#36852;&#22280;&#21312;&#22602;&#65292;&#20381;&#38468;&#20854;&#32302;&#25490;&#19979;&#30340;&#31243;&#24335;&#21312;&#22602;&#26371;&#37325;&#35079;&#22519;&#34892;&#65292;&#30452;&#21040;&#21487;&#36208;&#35370;&#29289;&#20214;&#20013;&#30340;&#25152;&#26377;&#20803;&#32032;&#37117;&#34987;&#36208;&#35370;&#23436;&#30050;&#12290;</p><pre><code>for i in ITERABLE: # start/stop/step
    # code block attached to for statement</code></pre><p>&#21487;&#36208;&#35370;&#29289;&#20214;&#34987;&#23459;&#21578;&#23436;&#25104;&#30340;&#30070;&#19979;&#65292;&#36852;&#22280;&#30340;&#19977;&#35201;&#32032;&#23601;&#24050;&#32147;&#25551;&#36848;&#23436;&#30050;&#12290;</p><ul><li><p>start&nbsp;&#21487;&#36845;&#20195;&#29289;&#20214;&#30340;&#31532; 0 &#38917;&#20803;&#32032;&#12290;</p></li><li><p>stop&nbsp;&#21487;&#36845;&#20195;&#29289;&#20214;&#30340;&#26368;&#24460;&#19968;&#38917;&#65288;&#32034;&#24341;&#20540; -1 &#30340;&#20803;&#32032;&#65289;&#12290;</p></li><li><p>step&nbsp;&#21487;&#36845;&#20195;&#29289;&#20214;&#30340;&#36887;&#34399;&#21312;&#38548;&#12290;</p></li></ul><p><code>ITERABLE</code> &#21487;&#20197;&#20839;&#24314;&#20989;&#25976; <code>range()</code> &#29983;&#25104;&#65292;&#20363;&#22914;&#21360;&#20986;&#21069; &#8;n &#20491;&#22855;&#25976;&#12290;</p><pre><code>help(range)
def print_first_n_odds(n):
    iterable = range(1, n*2, 2)
    for i in iterable:
        print(i)

print_first_n_odds(5)</code></pre><p>&#22312;&#21069;&#38754;&#30340;&#20363;&#23376;&#20013;&#65292;&#25105;&#20497;&#21487;&#20197;&#30475;&#21040;&#21516;&#27171;&#19968;&#20491;&#12300;&#21360;&#20986;&#21069; &#8;n &#20491;&#22855;&#25976;&#12301;&#30340;&#20989;&#25976;&#65292;&#21487;&#20197;&#29992;&#19981;&#21516;&#30340;&#36852;&#22280;&#39006;&#22411;&#20358;&#23526;&#20316;&#65292;&#37027;&#40636;&#22312;&#25033;&#29992;&#24773;&#22659;&#19978;&#65292;&#35442;&#22914;&#20309;&#21312;&#21029;&#33287;&#25505;&#29992;&#65311;&#31777;&#21934;&#20358;&#35498;&#65292;&#25105;&#20497;&#21487;&#20197;&#34249;&#30001;&#21028;&#26039;&#21312;&#22602;&#31243;&#24335;&#12300;&#37325;&#35079;&#22519;&#34892;&#30340;&#27425;&#25976;&#26159;&#21542;&#24050;&#30693;&#12301;&#20358;&#27770;&#23450;&#65292;&#24050;&#30693;&#37325;&#35079;&#22519;&#34892;&#27425;&#25976;&#30340;&#24773;&#22659;&#21487;&#20197;&#29992;&#20219;&#24847;&#36852;&#22280;&#65292;&#26410;&#30693;&#37325;&#35079;&#22519;&#34892;&#27425;&#25976;&#30340;&#24773;&#22659;&#20677;&#33021;&#25505;&#29992; <code>while</code> &#36852;&#22280;&#12290;&#36889;&#20491;&#35498;&#27861;&#26159;&#20381;&#25818; <code>while</code> &#36852;&#22280;&#33287; <code>for</code> &#36852;&#22280;&#30340;&#20027;&#35201;&#24046;&#21029;&#65292;<code>while</code> &#22312;&#37325;&#35079;&#22519;&#34892;&#21312;&#22602;&#31243;&#24335;&#30340;&#26178;&#20505;&#65292;&#26371;&#22312; <code>CONDITION</code> &#28858; <code>False</code> &#30340;&#26178;&#20505;&#32066;&#27490;&#65307;&#32780; <code>for</code> &#22312;&#37325;&#35079;&#22519;&#34892;&#21312;&#22602;&#31243;&#24335;&#30340;&#26178;&#20505;&#65292;&#26371;&#22312;&#21487;&#36845;&#20195;&#29289;&#20214;&#20013;&#30340;&#20803;&#32032;&#29992;&#32580;&#26178;&#20505;&#32066;&#27490;&#12290;&#36889;&#34920;&#31034; <code>while</code> &#36852;&#22280;&#26681;&#25818;&#19968;&#20491;&#22411;&#21029;&#28858;&#24067;&#26519;&#35722;&#25976;&#30340;&#29289;&#20214;&#27770;&#23450;&#37325;&#35079;&#22519;&#34892;&#31243;&#24335;&#21312;&#22602;&#26159;&#21542;&#32066;&#27490;&#65307;<code>for</code> &#36852;&#22280;&#21063;&#26681;&#25818;&#19968;&#20491;&#24050;&#30693;&#20803;&#32032;&#25976;&#37327;&#30340;&#21487;&#36845;&#20195;&#29289;&#20214;&#27770;&#23450;&#37325;&#35079;&#22519;&#34892;&#31243;&#24335;&#21312;&#22602;&#26159;&#21542;&#32066;&#27490;&#12290;&#33289;&#20363;&#20358;&#35498;&#65292;&#20839;&#24314;&#20989;&#25976; <code>bin()</code> &#21487;&#20197;&#23559;&#21313;&#36914;&#20301;&#25972;&#25976;&#36681;&#25563;&#28858;&#20108;&#36914;&#20301;&#25991;&#23383;&#65292;&#36681;&#25563;&#26041;&#24335;&#26159;&#36879;&#36942;&#12300;&#36670;&#36681;&#30456;&#38500;&#27861;&#12301;&#23559;&#21313;&#36914;&#20301;&#25972;&#25976;&#25345;&#32396;&#20197; 2 &#30456;&#38500;&#65292;&#30452;&#21040;&#21830;&#25976;&#30340;&#37096;&#20998;&#28858; 0 &#25110;&#32773; 1&#65292;&#20854;&#20013;&#12300;&#36670;&#36681;&#30456;&#38500;&#27861;&#12301;&#23601;&#26159;&#19968;&#20491;&#12300;&#26410;&#30693;&#37325;&#35079;&#22519;&#34892;&#27425;&#25976;&#12301;&#30340;&#24773;&#27841;&#65292;&#27794;&#26377;&#36774;&#27861;&#22312;&#19968;&#38283;&#22987;&#23601;&#24471;&#30693;&#38656;&#35201;&#22810;&#23569;&#27425;&#30340;&#36670;&#36681;&#30456;&#38500;&#25165;&#33021;&#32080;&#26463;&#12290;</p><pre><code>def int_to_bin_str(x):
    if x &lt; 2:
        return str(x)
    binary_str = ""
    while x &gt; 0:
        modulo = x % 2
        binary_str = str(modulo) + binary_str
        x //= 2
    return binary_str

print(int_to_bin_str(2))
print(int_to_bin_str(3))</code></pre><p>&#22312; Python &#20013;&#25152;&#35586;&#30340;&#21487;&#36208;&#35370;&#29289;&#20214;&#65288;Iterables&#65289;&#26159;&#20219;&#24847;&#38263;&#24230;&#30340;&#36039;&#26009;&#32080;&#27083;&#65288;&#21253;&#21547;&#20018;&#21015;&#12289;Tuples&#12289;&#38598;&#21512;&#12289;&#23383;&#20856;&#65289;&#25110;&#32773;&#25991;&#23383;&#65292;&#36889;&#20123;&#21487;&#36208;&#35370;&#29289;&#20214;&#37117;&#33021;&#22816;&#30452;&#25509;&#25918;&#32622;&#22312; <code>for</code> &#36852;&#22280;&#20013;&#20351;&#29992;&#12290;</p><pre><code>def print_iterable_elements(x):
    for e in x:
        print(e)

primes_list = [2, 3, 5, 7, 11]
primes_tuple = (2, 3, 5, 7, 11)
primes_set = {2, 3, 5, 7, 11}
primes_str = "2357"
print_iterable_elements(primes_list)
print_iterable_elements(primes_tuple)
print_iterable_elements(primes_set)
print_iterable_elements(primes_str)</code></pre><p>&#20294;&#23383;&#20856;&#26159;&#20855;&#26377;&#37749;&#65288;keys&#65289;&#33287;&#36039;&#26009;&#65288;values&#65289;&#30340;&#36039;&#26009;&#32080;&#27083;&#65292;&#22312;&#36208;&#26178;&#35201;&#29305;&#21029;&#30041;&#24847;&#26159;&#24076;&#26395;&#36208;&#35370;&#23383;&#20856;&#30340;&#37749;&#25110;&#32773;&#23383;&#20856;&#30340;&#20540;&#65292;&#36879;&#36942;&#23383;&#20856;&#30340;&nbsp;<code>keys()</code>&nbsp;&#12289;&nbsp;<code>values()</code>&nbsp;&#33287;&nbsp;<code>items()</code>&nbsp;&#26041;&#27861;&#20998;&#21029;&#21487;&#20197;&#21462;&#20986;&#37749;&#12289;&#36039;&#26009;&#25110;&#32773;&#20841;&#32773;&#65292;&#20854;&#20013;&nbsp;<code>items()</code>&nbsp;&#26041;&#27861;&#26371;&#23559;&#27161;&#31844;&#20197;&#21450;&#36039;&#26009;&#20841;&#20841;&#21512;&#20341;&#22312;&#19968;&#20491; Tuple &#20013;&#12290;</p><pre><code>primes_dict = {
    "1st": 2,
    "2nd": 3,
    "3rd": 5,
    "4th": 7,
    "5th": 11
}
# Iterating a dict
for k in primes_dict.keys():
    print(k)
for v in primes_dict.values():
    print(v)
for k, v in primes_dict.items():
    print("{} is the {} prime.".format(v, k))</code></pre><p>&#23559;&#27969;&#31243;&#25511;&#21046;&#30340;&#20841;&#20491;&#25216;&#24039;&#26781;&#20214;&#21028;&#26039;&#33287;&#36852;&#22280;&#21512;&#20341;&#20351;&#29992;&#26371;&#35731;&#25105;&#20497;&#30340;&#31243;&#24335;&#25776;&#23531;&#26356;&#26377;&#24392;&#24615;&#65292;&#20445;&#30041;&#23383;&nbsp;<code>break</code>&nbsp;&#33021;&#22816;&#35731;&#25105;&#20497;&#22312;&#36208;&#35370;&#30340;&#36942;&#31243;&#20013;&#22312;&#26781;&#20214;&#28858;&nbsp;<code>True</code>&nbsp;&#30340;&#26178;&#20505;&#32066;&#27490;&#36852;&#22280;&#65292;&#33289;&#20363;&#20358;&#35498;&#30070;&#36208;&#35370;&#21040;&#38750;&#25972;&#25976;&#30340;&#26178;&#20505;&#32066;&#27490;&#36852;&#22280;&#12290;</p><pre><code>primes = [2, 3, "5", 7, 11]
for p in primes:
    if not isinstance(p, int):
        break
    print(p)</code></pre><p>&#20445;&#30041;&#23383;&nbsp;<code>continue</code>&nbsp;&#33021;&#22816;&#35731;&#25105;&#20497;&#22312;&#36208;&#35370;&#30340;&#36942;&#31243;&#20013;&#22312;&#26781;&#20214;&#28858;&nbsp;<code>True</code>&nbsp;&#30340;&#26178;&#20505;&#30053;&#36942;&#35442;&#20803;&#32032;&#20294;&#26159;&#32380;&#32396;&#23436;&#25104;&#36852;&#22280;&#65292;&#33289;&#20363;&#20358;&#35498;&#30070;&#36208;&#35370;&#21040;&#38750;&#25972;&#25976;&#30340;&#26178;&#20505;&#30053;&#36942;&#12290;</p><pre><code>primes = [2, 3, "5", 7, 11]
for p in primes:
    if not isinstance(p, int):
        continue
    print(p)</code></pre><h2>&#20363;&#22806;&#34389;&#29702;</h2><p>&#20363;&#22806;&#34389;&#29702;&#25351;&#30340;&#26159;&#37341;&#23565;&#31243;&#24335;&#21312;&#22602;&#22519;&#34892;&#26178;&#25152;&#20986;&#29694;&#30340;&#20363;&#22806;&#65288;Exceptions&#65289;&#36914;&#34892;&#23565;&#25033;&#30340;&#34389;&#32622;&#65292;&#22312;&#22519;&#34892;&#31243;&#24335;&#21312;&#22602;&#26178;&#36973;&#36935;&#30340;&#20363;&#22806;&#24448;&#24448;&#26159;&#30001;&#26044;&#37679;&#35492;&#32780;&#24341;&#30332;&#65292;&#21253;&#21547;&#28961;&#25928;&#30340;&#29289;&#20214;&#21517;&#31281;&#12289;&#27284;&#26696;&#19981;&#23384;&#22312;&#25110;&#22411;&#21029;&#19981;&#27491;&#30906;&#31561;&#65292;&#37679;&#35492;&#26371;&#28961;&#26781;&#20214;&#20572;&#27490; Python &#31243;&#24335;&#65292;&#30772;&#22750;&#31243;&#24335;&#22519;&#34892;&#27491;&#24120;&#30340;&#27969;&#31243;&#65292;&#20363;&#22806;&#34389;&#29702;&#23601;&#26159;&#22312;&#31243;&#24335;&#21312;&#22602;&#36973;&#36935;&#20363;&#22806;&#26178;&#33021;&#22816;&#31227;&#20132;&#25511;&#21046;&#27402;&#30340;&#19968;&#31278;&#27231;&#21046;&#12290;&#31777;&#21934;&#20358;&#35498;&#65292;&#20363;&#22806;&#34389;&#29702;&#23601;&#20687;&#26159;&#21478;&#19968;&#31278;&#39006;&#22411;&#30340;&#26781;&#20214;&#21028;&#26039;&#65292;&#21482;&#19981;&#36942;&#26781;&#20214;&#21028;&#26039;&#20506;&#36084;&#26781;&#20214;&#30340;&#24067;&#26519;&#20540;&#27770;&#23450;&#21738;&#20491;&#31243;&#24335;&#21312;&#22602;&#35201;&#34987;&#22519;&#34892;&#65292;&#32780;&#20363;&#22806;&#34389;&#29702;&#21063;&#26159;&#20381;&#36084;&#31243;&#24335;&#21312;&#22602;&#26159;&#21542;&#29986;&#29983;&#20102;&#37679;&#35492;&#20358;&#27770;&#23450;&#21738;&#20491;&#31243;&#24335;&#21312;&#22602;&#35201;&#34987;&#22519;&#34892;&#12290;</p><p>&#25105;&#20497;&#21487;&#20197;&#20351;&#29992;&#20445;&#30041;&#23383; <code>try</code>&#12289;<code>except</code> &#33287;&#37679;&#35492;&#39006;&#21029;&#24314;&#31435;&#19968;&#20491;&#20363;&#22806;&#34389;&#29702;&#21312;&#22602;&#65292;&#20381;&#38468; <code>try</code> &#20445;&#30041;&#23383;&#32302;&#25490;&#19979;&#30340;&#31243;&#24335;&#21312;&#22602;&#19968;&#20294;&#22519;&#34892;&#26178;&#36973;&#36935;&#21040;&#20102;&#37679;&#35492;&#65292;&#23601;&#26371;&#36339;&#36942;&#35442;&#21312;&#22602;&#25913;&#28858;&#22519;&#34892;&#20381;&#38468; <code>except</code>&nbsp;&#20445;&#30041;&#23383;&#32302;&#25490;&#19979;&#30340;&#31243;&#24335;&#21312;&#22602;&#12290;</p><pre><code>try:
    # code block attached to try statement
except:
    # code block attached to except statement</code></pre><p>&#20363;&#22914;&#23559;&#36664;&#20837;&#30340;&#20841;&#25976;&#30456;&#38500;&#65292;&#22312;&#36664;&#20837;&#20841;&#25976;&#20854;&#20013;&#19968;&#32773;&#28858;&#25991;&#23383;&#26178;&#20505;&#26371;&#29986;&#29983;&#22411;&#21029;&#37679;&#35492;&#65288;TypeError&#65289;&#32780;&#23566;&#33268; Python &#31243;&#24335;&#22519;&#34892;&#20572;&#27490;&#65292;&#20063;&#22240;&#27492;&#22312;&#21628;&#21483; <code>divide()</code> &#20989;&#25976;&#24460;&#30340; <code>print()</code> &#20989;&#25976;&#37117;&#27794;&#26377;&#34987;&#22519;&#34892;&#12290;</p><pre><code>def divide(a, b):
    return a / b

print(divide(55, '0'))
print("This message will not be printed.")
print("This message will also not be printed.")</code></pre><p>&#21152;&#20837;&#20363;&#22806;&#34389;&#29702;&#65292;&#21487;&#20197;&#30906;&#20445;&#22312;&#21628;&#21483; <code>divide()</code> &#20989;&#25976;&#24460;&#30340; <code>print()</code> &#20989;&#25976;&#37117;&#26371;&#34987;&#22519;&#34892;&#12290;</p><pre><code>def divide(a, b):
    try:
        return a / b
    except:
        return None

print(divide(55, '0'))
print("This message will be printed.")
print("This message will also be printed.")</code></pre><p>&#33509;&#22312;&#20445;&#30041;&#23383; <code>except</code> &#20043;&#24460;&#21152;&#19978;&#37679;&#35492;&#39006;&#21029;&#21487;&#20197;&#20381;&#29031;&#29986;&#29983;&#30340;&#37679;&#35492;&#65292;&#22238;&#20659;&#19981;&#21516;&#30340;&#23565;&#25033;&#36664;&#20986;&#12290;</p><pre><code>def divide(a, b):
    try:
        return a / b
    except TypeError:
        return "TypeError occurred."
    except ZeroDivisionError:
        return "ZeroDivisionError occured."

print(divide(55, '0'))
print(divide(55, 0))
print("This message will be printed.")
print("This message will also be printed.")</code></pre><p>&#22312;&#35469;&#35672;&#20102;&#26781;&#20214;&#21028;&#26039;&#12289;&#36852;&#22280;&#33287;&#20363;&#22806;&#34389;&#29702;&#36889;&#19977;&#31278;&#27969;&#31243;&#25511;&#21046;&#30340;&#27231;&#21046;&#20043;&#24460;&#65292;&#31532;&#21313;&#20116;&#36913;&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;Python &#30340;&#27969;&#31243;&#25511;&#21046;&#20358;&#21040;&#23614;&#32882;&#65292;&#24076;&#26395;&#24744;&#20063;&#21644;&#25105;&#19968;&#27171;&#26399;&#24453;&#19979;&#19968;&#31687;&#25991;&#31456;&#12290;</p><h2>&#35336;&#30059;&#23416;&#21729;&#23560;&#21312;</h2><p>&#32004;&#32173;&#23433;&#35336;&#30059;&#23416;&#21729;&#21487;&#20197;&#40670;&#36984; nbgitpuller &#36899;&#32080;&#23559;&#26412;&#31687;&#25991;&#31456;&#23436;&#25972;&#30340; Jupyter Notebook &#35079;&#35069;&#21040;&#33258;&#24049;&#30340; JupyterHub &#20043;&#20013;&#65306;</p><p><a href="https://lab.datainpoint.com/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fdatainpoint%2Fweek-fifteen-control-flow-in-python&amp;urlpath=tree%2Fweek-fifteen-control-flow-in-python%2Fnotebook.ipynb&amp;branch=main">nbgitpuller &#36899;&#32080;</a></p><p>&#20282;&#26381;&#22120;&#36984;&#38917;&#36984;&#25799;&#38928;&#35373;&#30340;&#12300;Data science environment&#65306;&#23416;&#32722; Python&#12289;R &#33287; Julia &#30340;&#36039;&#26009;&#31185;&#23416;&#29872;&#22659;&#12301;&#23601;&#21487;&#20197;&#38918;&#21033;&#36939;&#20316;&#25991;&#31456;&#20013;&#30340;&#31684;&#20363;&#31243;&#24335;&#12290;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HMwv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HMwv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 424w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 848w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1272w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!HMwv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png" width="1456" height="964" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:964,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:137396,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!HMwv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 424w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 848w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1272w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#36984;&#25799;&#12300;Data science environment&#65306;&#23416;&#32722; Python&#12289;R &#33287; Julia &#30340;&#36039;&#26009;&#31185;&#23416;&#29872;&#22659;&#12301;</figcaption></figure></div><h2>&#24310;&#20280;&#38321;&#35712;</h2><ol><li><p><a href="https://docs.python.org/3/tutorial/errors.html">https://docs.python.org/3/tutorial/errors.html</a></p></li></ol><div><hr></div><p>&#23565;&#26044;&#36889;&#31687;&#25991;&#31456;&#26377;&#20160;&#40636;&#24819;&#27861;&#21602;&#65311;&#21916;&#27489;&#128571;&#12289;&#30041;&#35328;&#128587;&#8205;&#9794;&#65039;&#25110;&#32773;&#20998;&#20139;&#128588;</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://datainpoint.substack.com/p/week-fifteen-control-flow-in-python/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://datainpoint.substack.com/p/week-fifteen-control-flow-in-python/comments"><span>Leave a comment</span></a></p>]]></content:encoded></item><item><title><![CDATA[約維安計畫：Python 的資料結構]]></title><description><![CDATA[&#31532;&#21313;&#22235;&#36913;&#12290;]]></description><link>https://datainpoint.substack.com/p/week-fourteen-data-structures-in-python</link><guid isPermaLink="false">https://datainpoint.substack.com/p/week-fourteen-data-structures-in-python</guid><dc:creator><![CDATA[Yao-Jen Kuo]]></dc:creator><pubDate>Tue, 17 Aug 2021 15:38:15 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!qh8o!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fada509f2-14c9-4f0b-8728-2a06e7789c16_1200x628.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qh8o!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fada509f2-14c9-4f0b-8728-2a06e7789c16_1200x628.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qh8o!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fada509f2-14c9-4f0b-8728-2a06e7789c16_1200x628.gif 424w, https://substackcdn.com/image/fetch/$s_!qh8o!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fada509f2-14c9-4f0b-8728-2a06e7789c16_1200x628.gif 848w, https://substackcdn.com/image/fetch/$s_!qh8o!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fada509f2-14c9-4f0b-8728-2a06e7789c16_1200x628.gif 1272w, https://substackcdn.com/image/fetch/$s_!qh8o!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fada509f2-14c9-4f0b-8728-2a06e7789c16_1200x628.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qh8o!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fada509f2-14c9-4f0b-8728-2a06e7789c16_1200x628.gif" width="1200" height="628" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/ada509f2-14c9-4f0b-8728-2a06e7789c16_1200x628.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:628,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:516447,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!qh8o!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fada509f2-14c9-4f0b-8728-2a06e7789c16_1200x628.gif 424w, https://substackcdn.com/image/fetch/$s_!qh8o!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fada509f2-14c9-4f0b-8728-2a06e7789c16_1200x628.gif 848w, https://substackcdn.com/image/fetch/$s_!qh8o!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fada509f2-14c9-4f0b-8728-2a06e7789c16_1200x628.gif 1272w, https://substackcdn.com/image/fetch/$s_!qh8o!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fada509f2-14c9-4f0b-8728-2a06e7789c16_1200x628.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#20358;&#28304;&#65306;giphy.com</figcaption></figure></div><h2>&#20160;&#40636;&#26159;&#36039;&#26009;&#32080;&#27083;</h2><p>&#22312;<a href="https://datainpoint.substack.com/p/week-thirteen-functions-and-data-types-in-python">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;&#31532;&#21313;&#19977;&#36913;</a>&#20013;&#25105;&#20497;&#24050;&#32147;&#30693;&#36947; Python &#30340;&#22522;&#26412;&#36039;&#26009;&#22411;&#21029;&#65292;&#21253;&#21547;&#25972;&#25976;&#12289;&#28014;&#40670;&#25976;&#12289;&#25991;&#23383;&#12289;&#24067;&#26519;&#33287;&#26410;&#23450;&#32681;&#20540;&#65292;&#36039;&#26009;&#22411;&#21029;&#22312;&#31243;&#24335;&#35373;&#35336;&#20013;&#25152;&#25198;&#28436;&#30340;&#35282;&#33394;&#23601;&#20687;&#26159;&#27138;&#39640;&#12289;&#31309;&#26408;&#12289;&#27169;&#22411;&#25110;&#25340;&#22294;&#31561;&#36938;&#25138;&#20013;&#30340;&#22522;&#26412;&#21934;&#20803;&#38646;&#20214;&#65292;&#36879;&#36942;&#32080;&#21512;&#36039;&#26009;&#22411;&#21029;&#65292;&#21487;&#20197;&#22534;&#30090;&#20986;&#26356;&#36914;&#38542;&#30340; Python &#25033;&#29992;&#65292;&#25509;&#19979;&#20358;&#25105;&#20497;&#26371;&#24478;&#36039;&#26009;&#22411;&#21029;&#36993;&#21521;&#32080;&#27083;&#65288;Structures&#65289;&#12290;&#22312;&#38651;&#33126;&#31185;&#23416;&#20013;&#65292;&#36039;&#26009;&#32080;&#27083;&#26159;&#38651;&#33126;&#20786;&#23384;&#12289;&#32068;&#32340;&#20197;&#21450;&#23384;&#21462;&#36039;&#26009;&#30340;&#27231;&#21046;&#65292;&#22312; Python &#20013;&#25105;&#20497;&#21487;&#20197;&#36879;&#36942;&#22235;&#31278;&#22522;&#26412;&#36039;&#26009;&#32080;&#27083;&#20358;&#20786;&#23384;&#12289;&#32068;&#32340;&#20197;&#21450;&#23384;&#21462;&#25105;&#20497;&#22312;<a href="https://datainpoint.substack.com/p/week-thirteen-functions-and-data-types-in-python">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;&#31532;&#21313;&#19977;&#36913;</a>&#25152;&#35469;&#35672;&#30340;&#36039;&#26009;&#22411;&#21029;&#12290;</p><ol><li><p>&#20018;&#21015; <code>list</code></p></li><li><p><code>tuple</code></p></li><li><p>&#23383;&#20856; <code>dict</code></p></li><li><p>&#38598;&#21512; <code>set</code></p></li></ol><h2>&#20197; type() &#20989;&#25976;&#35672;&#21029;&#36039;&#26009;&#32080;&#27083;</h2><p>&#21644;&#36039;&#26009;&#22411;&#21029;&#30340;&#25033;&#29992;&#22580;&#26223;&#30456;&#21516;&#65292;&#24120;&#35211;&#23565;&#36039;&#26009;&#32080;&#27083;&#25033;&#29992;&#20989;&#25976;&#25110;&#32773;&#21628;&#21483;&#36039;&#26009;&#32080;&#27083;&#26412;&#36523;&#30340;&#26041;&#27861;&#26178;&#20505;&#65292;&#37117;&#26159;&#23565;&#25033;&#23436;&#25104;&#23459;&#21578;&#30340;&#29289;&#20214;&#25033;&#29992;&#65292;&#32780;&#38750;&#30452;&#25509;&#23565;&#25033;&#36039;&#26009;&#32080;&#27083;&#65292;&#36889;&#26159;&#22240;&#28858;&#31243;&#24335;&#35373;&#35336;&#36890;&#24120;&#22312;&#24460;&#32396;&#26371;&#26377;&#36039;&#26009;&#35352;&#37636;&#33287;&#36939;&#31639;&#34389;&#29702;&#30340;&#38656;&#27714;&#65292;&#20006;&#19981;&#20677;&#27490;&#33287;&#23559;&#20854;&#21360;&#20986;&#20358;&#32780;&#24050;&#12290;&#25152;&#20197;&#25105;&#20497;&#21487;&#20197;&#36939;&#29992;&#33021;&#22816;&#23559;&#23436;&#25104;&#23459;&#21578;&#30340;&#29289;&#20214;&#25152;&#20786;&#23384;&#20043;&#36039;&#26009;&#32080;&#27083;&#21578;&#30693;&#20351;&#29992;&#32773;&#30340;&#20839;&#24314;&#20989;&#25976;&nbsp;<code>type()&#65292;</code>&#20316;&#29992;&#26159;&#23559;&#34987;&#25033;&#29992;&#29289;&#20214;&#30340;&#39006;&#21029;&#22238;&#20659;&#65292;&#22312; Python &#20013;&#29289;&#20214;&#65288;Objects&#65289;&#26159;&#39006;&#21029;&#65288;Classes&#65289;&#30340;&#23526;&#20363;&#65288;Instances&#65289;&#65292;&#32780;&#39006;&#21029;&#26377;&#20998;&#28858;&#36039;&#26009;&#22411;&#21029;&#12289;&#36039;&#26009;&#32080;&#27083;&#12289;&#20989;&#25976;&#20197;&#21450;&#29305;&#27530;&#39006;&#21029;&#65288;&#20363;&#22914;&#33258;&#34892;&#23450;&#32681;&#39006;&#21029;&#12289;&#29986;&#29983;&#22120;&#25110;&#36845;&#20195;&#22120;&#31561;&#36914;&#38542;&#30340; Python &#39006;&#21029;&#65289;&#12290;</p><pre><code>primes_list = [2, 3, 5, 7, 11]
primes_tuple = (2, 3, 5, 7, 11)
primes_dict = {
    "1st": 2,
    "2nd": 3,
    "3rd": 5,
    "4th": 7,
    "5th": 11
}
primes_set = {2, 3, 5, 7, 11}
print(type(primes_list))
print(type(primes_tuple))
print(type(primes_dict))
print(type(primes_set))
## &lt;class 'list'&gt;
## &lt;class 'tuple'&gt;
## &lt;class 'dict'&gt;
## &lt;class 'set'&gt;</code></pre><h2>&#20989;&#25976;&#30340;&#20351;&#29992;&#26041;&#24335;</h2><p>&#22312; Python &#20013;&#20351;&#29992;&#20989;&#25976;&#26377;&#20841;&#31278;&#27231;&#21046;&#65292;&#19968;&#26159;&#23565;&#36039;&#26009;&#22411;&#21029;&#25110;&#36039;&#26009;&#32080;&#27083;&#25033;&#29992;&#20989;&#25976;&#65307;&#20108;&#26159;&#21628;&#21483;&#8;&#32129;&#23450;&#26044;&#36039;&#26009;&#22411;&#21029;&#25110;&#36039;&#26009;&#32080;&#27083;&#30340;&#26041;&#27861;&#65292;&#36889;&#26178;&#35201;&#27880;&#24847;&#65292;&#25105;&#20497;&#19981;&#20877;&#31281;&#21628;&#12300;&#20989;&#25976;&#12301;&#65292;&#32780;&#26159;&#25913;&#31281;&#12300;&#26041;&#27861;&#12301;&#12290;</p><p>&#33289;&#19968;&#20491;&#20363;&#23376;&#35498;&#26126;&#65292;Python &#26377;&#19968;&#20491;&#20839;&#24314;&#20989;&#25976; <code>sorted()</code>&#65292;&#20018;&#21015;&#26377;&#19968;&#20491;&#26041;&#27861; <code>sort()</code>&#65292;&#20841;&#32773;&#37117;&#33021;&#22816;&#25490;&#24207;&#19968;&#20491;&#20018;&#21015;&#65292;&#20294;&#26159;&#22312;&#20351;&#29992;&#30340;&#35486;&#27861;&#33287;&#24847;&#32681;&#19978;&#19981;&#21516;&#65292;&#20351;&#29992;&#20839;&#24314;&#20989;&#25976; <code>sorted()</code> &#25490;&#24207;&#20018;&#21015;&#26159;&#25105;&#20497;&#32722;&#24931;&#19988;&#30452;&#35264;&#30340;&#12300;&#23565;&#36039;&#26009;&#32080;&#27083;&#25033;&#29992;&#20989;&#25976;&#12301;&#65292;&#35486;&#27861;&#26159; <code>sorted(a_list_to_be_sorted)</code>&#65307;&#20351;&#29992;&#20018;&#21015;&#26041;&#27861; <code>sort()</code> &#25490;&#24207;&#26159;&#25105;&#20497;&#36611;&#28858;&#38476;&#29983;&#30340;&#12300;&#21628;&#21483;&#32129;&#23450;&#26044;&#36039;&#26009;&#32080;&#27083;&#30340;&#26041;&#27861;&#12301;&#65292;&#35486;&#27861;&#26159; <code>a_list_to_be_sorted.sort()</code>&#12290;</p><pre><code>primes_list = [11, 7, 5, 3, 2]
sorted(primes_list) # Apply sorted function to primes_list
primes_list.sort()  # Call sort method of primes_list</code></pre><p>&#38500;&#20102;&#36889;&#20841;&#31278;&#20989;&#25976;&#20351;&#29992;&#30340;&#27231;&#21046;&#24046;&#30064;&#65292;&#21478;&#22806;&#19968;&#20491;&#20540;&#24471;&#27880;&#24847;&#20043;&#34389;&#22312;&#26044;&#20989;&#25976;&#30340;&#25033;&#29992;&#20197;&#21450;&#26041;&#27861;&#30340;&#21628;&#21483;&#37117;&#21487;&#33021;&#26377;&#20841;&#31278;&#35731;&#25033;&#29992;&#25110;&#32773;&#32129;&#23450;&#30340;&#36039;&#26009;&#22411;&#21029;&#33287;&#36039;&#26009;&#32080;&#27083;&#36896;&#25104;&#26356;&#21205;&#30340;&#27231;&#21046;&#65292;&#19968;&#26159;&#20197;&#22238;&#20659;&#20540;&#22411;&#24907;&#36664;&#20986;&#26356;&#21205;&#24460;&#30340;&#32080;&#26524;&#65307;&#20108;&#26159;&#30452;&#25509;&#26356;&#21205;&#36039;&#26009;&#22411;&#21029;&#33287;&#36039;&#26009;&#32080;&#27083;&#32780;&#27794;&#26377;&#36664;&#20986;&#12290;&#36889;&#20491;&#24046;&#30064;&#33021;&#22816;&#24310;&#32396;&#21069;&#36848;&#20839;&#24314;&#20989;&#25976; <code>sorted()</code> &#33287;&#20018;&#21015;&#26041;&#27861; <code>sort()</code> &#30340;&#20363;&#23376;&#65292;<code>sorted(a_list_to_be_sorted)</code> &#26159;&#20197;&#22238;&#20659;&#20540;&#36664;&#20986;&#25490;&#24207;&#24460;&#30340;&#20018;&#21015;&#65292;&#22240;&#27492;&#22914;&#26524;&#27794;&#26377;&#23559;&#22238;&#20659;&#20540;&#26356;&#26032;&#21407;&#26412;&#21629;&#21517;&#30340;&#20018;&#21015;&#65292;&#25490;&#24207;&#30340;&#26356;&#21205;&#20006;&#19981;&#26371;&#34987;&#20445;&#30041;&#12290;</p><pre><code>primes_list = [11, 7, 5, 3, 2]
sorted(primes_list) # Apply sorted function to primes_list
print(primes_list)  # primes_list is not sorted
primes_list = sorted(primes_list)  # Update primes_list with function output
print(primes_list)  # primes_list is now sorted
## [11, 7, 5, 3, 2]
## [2, 3, 5, 7, 11]</code></pre><p>&#32780; <code>a_list_to_be_sorted.sort()</code> &#21063;&#26159;&#30452;&#25509;&#23559;&#25490;&#24207;&#26356;&#21205;&#20102;&#65292;&#19981;&#38656;&#35201;&#26356;&#26032;&#21407;&#26412;&#21629;&#21517;&#30340;&#20018;&#21015;&#65292;&#20063;&#19981;&#26371;&#20276;&#38568;&#26377;&#22238;&#20659;&#20540;&#12290;</p><pre><code>primes_list = [11, 7, 5, 3, 2]
primes_list.sort()  # Call sort method of primes_list
print(primes_list)  # primes_list is sorted
## [2, 3, 5, 7, 11]</code></pre><p>&#20989;&#25976;&#25110;&#32773;&#26041;&#27861;&#22810;&#25976;&#24773;&#27841;&#19979;&#26371;&#22312;&#12300;&#20197;&#22238;&#20659;&#20540;&#36664;&#20986;&#12301;&#25110;&#12300;&#30452;&#25509;&#26356;&#21205;&#29289;&#20214;&#29376;&#24907;&#12301;&#20013;&#25799;&#19968;&#65292;&#23569;&#25976;&#24773;&#27841;&#19979;&#20063;&#26371;&#26377;&#20841;&#32773;&#20860;&#20855;&#30340;&#24773;&#27841;&#65292;&#20363;&#22914;&#20018;&#21015;&#26041;&#27861; pop() &#33021;&#22816;&#23559;&#20018;&#21015;&#26411;&#31471;&#30340;&#36039;&#26009;&#25291;&#20986;&#28858;&#22238;&#20659;&#20540;&#65292;&#20006;&#21034;&#38500;&#20018;&#21015;&#26411;&#31471;&#30340;&#36039;&#26009;&#40670;&#12290;</p><pre><code>primes_list = [11, 7, 5, 3, 2]
the_last_element = primes_list.pop()
print(primes_list)       # The last element was deleted
print(the_last_element)  # The last element was returned
## [11, 7, 5, 3]
## 2</code></pre><h2>&#20018;&#21015;</h2><p>&#20018;&#21015; <code>list</code> &#26159; Python &#26368;&#22522;&#30990;&#19988;&#26368;&#28858;&#24120;&#29992;&#30340;&#36039;&#26009;&#32080;&#27083;&#65292;&#21487;&#20197;&#23481;&#32013;&#19981;&#21516;&#30340;&#36039;&#26009;&#22411;&#21029;&#33287;&#36039;&#26009;&#32080;&#27083;&#65292;&#24314;&#31435;&#30340;&#26178;&#20505;&#20351;&#29992;&#20013;&#25324;&#34399;&nbsp;<code>[]</code>&nbsp;&#23559;&#24076;&#26395;&#20786;&#23384;&#30340;&#36039;&#26009;&#22411;&#21029;&#33287;&#36039;&#26009;&#32080;&#27083;&#21253;&#25324;&#36215;&#20358;&#65292;&#20006;&#23559;&#24076;&#26395;&#23384;&#25918;&#30340;&#36039;&#26009;&#22411;&#21029;&#33287;&#36039;&#26009;&#32080;&#27083;&#20197;&#36887;&#34399;&#20998;&#38548;&#12290;</p><pre><code>primes_list = [2, 3, 5, 7, 11]
print(type(primes_list))
## &lt;class 'list'&gt;</code></pre><p>&#26377;&#26178;&#20505;&#25105;&#20497;&#20063;&#20351;&#29992; Python &#30340;&#20839;&#24314;&#20989;&#25976;&nbsp;<code>list()</code>&nbsp;&#20358;&#24314;&#31435;&#20018;&#21015;&#65292;&#20363;&#22914;&#24120;&#34987;&#29992;&#20358;&#29983;&#25104;&#25976;&#21015;&#30340;&#20839;&#24314;&#20989;&#25976;&nbsp;<code>range()</code>&nbsp;&#20854;&#36664;&#20986;&#26159;&#19968;&#20491;&#21487;&#20197;&#34987;&#36845;&#20195;&#30340;&#29289;&#20214;&#65288;Iterable&#65289;&#65292;&#23660;&#26044; <code>range</code> &#39006;&#21029;&#65292;&#22914;&#26524;&#30452;&#25509;&#25033;&#29992;&#19981;&#26371;&#34987;&#21360;&#20986;&#25152;&#26377;&#30340;&#25976;&#23383;&#65292;&#36889;&#26178;&#21487;&#20197;&#29992; <code>list()</code> &#20989;&#25976;&#23559;&#23427;&#36681;&#25563;&#28858; <code>list</code> &#20358;&#35264;&#23519;&#20854;&#20013;&#21253;&#21547;&#30340;&#25976;&#23383;&#12290;</p><pre><code>integer_sequence = range(10)
print(integer_sequence)
print(list(integer_sequence))
## range(0, 10)
## [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]</code></pre><p>&#20351;&#29992;&#20018;&#21015;&#23559;&#22810;&#31558;&#36039;&#26009;&#22411;&#21029;&#25110;&#32080;&#27083;&#20786;&#23384;&#26044;&#19968;&#20491;&#29289;&#20214;&#20043;&#20013;&#65292;&#23601;&#20687;&#26159;&#22312;&#36914;&#34892;<strong>&#21270;&#38646;&#28858;&#25972;</strong>&#30340;&#24037;&#20316;&#65292;&#36889;&#34920;&#31034; Python &#24517;&#28982;&#20063;&#33021;&#22816;&#35731;&#25105;&#20497;&#36914;&#34892;&#36870;&#21521;&#24037;&#31243;&#65306;<strong>&#21270;&#25972;&#28858;&#38646;</strong>&#65292;&#21270;&#25972;&#28858;&#38646;&#30340;&#23560;&#26377;&#21517;&#31281;&#28858;&#23376;&#38598;&#65288;Subset&#65289;&#65292;&#20018;&#21015;&#30340;&#23376;&#38598;&#25805;&#20316;&#25216;&#24039;&#21487;&#20197;&#20998;&#28858;&#20841;&#31278;&#65306;</p><ol><li><p>&#32034;&#24341;&#65288;Indexing&#65289;</p></li><li><p>&#20999;&#21106;&#65288;Slicing&#65289;</p></li></ol><p>&#21033;&#29992;&#20839;&#24314;&#20989;&#25976;&nbsp;<code>len()</code>&nbsp;&#21487;&#20197;&#20808;&#26296;&#35299;&#25105;&#20497;&#24819;&#35201;&#21462;&#28858;&#23376;&#38598;&#30340;&#20018;&#21015;&#38263;&#24230;&#65288;&#20134;&#21363;&#20018;&#21015;&#20013;&#25152;&#20786;&#23384;&#30340;&#20803;&#32032;&#20491;&#25976;&#65289;&#65292;&#36914;&#32780;&#20877;&#21033;&#29992;&#32034;&#24341;&#12289;&#20999;&#21106;&#30340;&#25216;&#27861;&#12290;</p><pre><code>primes_list = [2, 3, 5, 7, 11]
len_primes_list = len(primes_list)
print(len_primes_list)
# 5</code></pre><p>&#36984;&#25799;&#20018;&#21015;&#20013;&#30340;&#36039;&#26009;&#25105;&#20497;&#20351;&#29992;&#20013;&#25324;&#34399;&nbsp;<code>[]</code>&nbsp;&#25645;&#37197;&#32034;&#24341;&#20540;&#65292;&#20540;&#24471;&#27880;&#24847;&#30340;&#26159;&#32034;&#24341;&#20540;&#24478;&#24038;&#37002;&#30001; 0 &#38283;&#22987;&#65292;&#32780;&#38750;&#30001; 1 &#38283;&#22987;&#12290;</p><pre><code># start from left at index 0
print(primes_list[0])
print(primes_list[1])
print(primes_list[2])
print(primes_list[3])
print(primes_list[len_primes_list - 1])
## 2
## 3
## 5
## 7
## 11</code></pre><p>&#24478;&#21491;&#37002;&#21063;&#30001; -1 &#38283;&#22987;&#12290;</p><pre><code># start from right at index -1
print(primes_list[-1])
print(primes_list[-2])
print(primes_list[-3])
print(primes_list[-4])
print(primes_list[-len_primes_list])
## 11
## 7
## 5
## 3
## 2</code></pre><p>&#21033;&#29992;&nbsp;<code>[start:stop:step]</code>&nbsp;&#35486;&#27861;&#23565;&#20018;&#21015;&#25351;&#23450;&#35201;&#20999;&#21106;&#20986;&#20358;&#30340;&#23376;&#38598;&#65292;&#20854;&#20013;&nbsp;<code>stop</code>&nbsp;&#19981;&#26371;&#20986;&#29694;&#22312;&#26368;&#24460;&#36984;&#25799;&#20986;&#20358;&#30340;&#32080;&#26524;&#20013;&#65292;&#20363;&#22914;&#25105;&#20497;&#24076;&#26395;&#23559;&#20301;&#26044;&nbsp;<code>[0]</code>&nbsp;&#12289;&nbsp;<code>[1]</code>&nbsp;&#12289;&nbsp;<code>[2]</code>&nbsp;&#30340;&#36039;&#26009;&#21478;&#22806;&#20999;&#21106;&#28858;&#19968;&#20491;&#38263;&#24230;&#28858; 3 &#30340;&#20018;&#21015;&#65292;&#35201;&#20351;&#29992;&nbsp;<code>[0:3]</code>&nbsp;&#32780;&#38750;&nbsp;<code>[0:2]</code>&#12290;</p><pre><code><code>print(primes_list[0:3])
## [2, 3, 5]</code></code></pre><p>&#20351;&#29992;&#20999;&#21106;&#30340;&#35486;&#27861;&#26178;&#65292;&nbsp;<code>start</code>&nbsp;&#12289;&nbsp;<code>stop</code>&nbsp;&#33287;&nbsp;<code>step</code>&nbsp;&#36889;&#19977;&#20491;&#21443;&#25976;&#37117;&#26377;&#38928;&#35373;&#20540;&#65292;&nbsp;<code>start</code>&nbsp;&#38928;&#35373;&#26159; 0&#65292;&nbsp;<code>stop</code>&nbsp;&#38928;&#35373;&#28858;&#20018;&#21015;&#30340;&#38263;&#24230;&#65292;&nbsp;<code>step</code>&nbsp;&#38928;&#35373;&#28858; 1&#65292;&#20551;&#22914;&#27794;&#26377;&#25351;&#23450;&#23601;&#25505;&#38928;&#35373;&#20540;&#65292;&#20687;&#26159;&#20999;&#21106;&#20986;&#20301;&#26044;&nbsp;<code>[0]</code>&nbsp;&#12289;&nbsp;<code>[2]</code>&nbsp;&#33287;&nbsp;<code>[4]</code>&nbsp;&#36889;&#19977;&#20491;&#20301;&#32622;&#30340;&#36039;&#26009;&#21487;&#20197;&#31777;&#21934;&#20351;&#29992;&nbsp;<code>[::2]</code>&nbsp;&#12290;</p><pre><code>print(primes_list[::2])
## [2, 5, 11]</code></pre><p>&#27604;&#36611;&#29305;&#21029;&#30340;&nbsp;<code>step</code>&nbsp;&#21443;&#25976;&#22914;&#26524;&#25351;&#23450;&#28858; -1 &#21487;&#20197;&#23559;&#20018;&#21015;&#20013;&#30340;&#36039;&#26009;&#38918;&#24207;&#21453;&#36681;&#65288;Reverse&#65289;&#12290;</p><pre><code><code>print(primes_list[::-1])
## [11, 7, 5, 3, 2]</code></code></pre><p>&#38500;&#20102;&#32034;&#24341;&#33287;&#20999;&#21106;&#65292;&#24120;&#29992;&#30340;&#20018;&#21015;&#25805;&#20316;&#36996;&#26377;&#26032;&#22686;&#12289;&#21034;&#38500;&#33287;&#25490;&#24207;&#36039;&#26009;&#65292;&#26032;&#22686;&#21487;&#20197;&#20351;&#29992;<code>&#20018;&#21015;&#30340;append()</code>&nbsp;&#26041;&#27861;&#23559;&#36039;&#26009;&#21152;&#20837;&#21040;&#20018;&#21015;&#26411;&#31471;&#65292;&#36889;&#20491;&#26041;&#27861;&#25505;&#29992;&#30452;&#25509;&#26356;&#21205;&#27794;&#26377;&#36664;&#20986;&#30340;&#27231;&#21046;&#12290;</p><pre><code>primes_list = [2, 3, 5, 7, 11]
primes_list.append(13)
print(primes_list)  # 13 was appended to primes_list
## [2, 3, 5, 7, 11, 13]</code></pre><p>&#21034;&#38500;&#21487;&#20197;&#20351;&#29992;&#20018;&#21015;&#30340;&nbsp;<code>pop()</code>&nbsp;&#26041;&#27861;&#23559;&#20018;&#21015;&#26411;&#31471;&#30340;&#36039;&#26009;&#25291;&#20986;&#65292;&#36889;&#20491;&#26041;&#27861;&#21516;&#26178;&#25505;&#29992;&#22238;&#20659;&#20540;&#33287;&#30452;&#25509;&#26356;&#21205;&#30340;&#27231;&#21046;&#12290;</p><pre><code>primes_list.pop()  # 13 is popped out and returned
print(primes_list) # 13 was deleted
## [2, 3, 5, 7, 11]</code></pre><p>&#25490;&#24207;&#21487;&#20197;&#20351;&#29992;&#20018;&#21015;&#30340;&nbsp;<code>sort()</code>&nbsp;&#26041;&#27861;&#23559;&#20018;&#21015;&#30340;&#36039;&#26009;&#20197;&#36958;&#22686;&#25490;&#24207;&#65292;&#20134;&#21487;&#20197;&#25351;&#23450;<code>&#21443;&#25976; reverse=True</code> &#20197;&#36958;&#28187;&#25490;&#24207;&#65292;&#36889;&#20491;&#26041;&#27861;&#25505;&#29992;&#30452;&#25509;&#26356;&#21205;&#27794;&#26377;&#36664;&#20986;&#30340;&#27231;&#21046;&#12290;</p><pre><code>primes_list = [2, 3, 5, 7, 11]
primes_list.sort(reverse=True)
print(primes_list) # primes_list is now sorted with descending order
primes_list.sort()
print(primes_list) # primes_list is now sorted with ascending order
## [11, 7, 5, 3, 2]
## [2, 3, 5, 7, 11]</code></pre><h2>Tuples</h2><p><code>tuple</code> &#26159; Python &#21478;&#19968;&#24120;&#29992;&#30340;&#36039;&#26009;&#32080;&#27083;&#65292;&#22810;&#25976;&#30340;&#29305;&#24615;&#37117;&#33287;&#20018;&#21015;&#30456;&#21516;&#65292;&#20363;&#22914;&#22312;&#32034;&#24341;&#33287;&#20999;&#21106;&#30340;&#37096;&#20998;&#33287;&#20018;&#21015;&#25805;&#20316;&#35486;&#27861;&#23436;&#20840;&#30456;&#21516;&#12290;&#22312;&#24314;&#31435;&#30340;&#26178;&#20505;&#20351;&#29992;&#23567;&#25324;&#34399;&nbsp;<code>()</code>&nbsp;&#23559;&#24076;&#26395;&#20786;&#23384;&#30340;&#36039;&#35338;&#21253;&#25324;&#36215;&#20358;&#65292;&#20006;&#23559;&#24076;&#26395;&#23384;&#25918;&#30340;&#36039;&#26009;&#22411;&#21029;&#33287;&#36039;&#26009;&#32080;&#27083;&#20197;&#36887;&#34399;&#20998;&#38548;&#12290;</p><pre><code>primes_tuple = (2, 3, 5, 7, 11)
print(type(primes_tuple))
## &lt;class 'tuple'&gt;</code></pre><p><code>tuple</code> &#33287;&#20018;&#21015;&#26368;&#22823;&#30340;&#24046;&#30064;&#22312;&#26044; <code>tuple</code> &#26159;&#19981;&#21487;&#35722;&#21205;&#65288;Immutable&#65289;&#30340;&#36039;&#26009;&#32080;&#27083;&#65292;&#19981;&#20855;&#20633;&#20219;&#20309;&#21253;&#21547;&#26032;&#22686;&#12289;&#21034;&#38500;&#33287;&#25490;&#24207;&#36039;&#26009;&#30340;&#25805;&#20316;&#65292;&#36889;&#27171;&#30340;&#29305;&#24615;&#35731; <code>tuple</code> &#34987;&#35373;&#35336;&#22312;&#20989;&#25976;&#30340;&#24392;&#24615;&#21443;&#25976;&#33287;&#38928;&#35373;&#22810;&#20491;&#22238;&#20659;&#20540;&#20043;&#20013;&#12290;&#33258;&#34892;&#23450;&#32681;&#20989;&#25976;&#26178;&#22914;&#26524;&#24076;&#26395;&#21443;&#25976;&#28858;&#19981;&#23450;&#20491;&#25976;&#65292;&#20363;&#22914;&#19968;&#20491;&#33021;&#22816;&#36914;&#34892;&#20841;&#20491;&#25976;&#23383;&#12289;&#19977;&#20491;&#25976;&#23383;&#29978;&#33267; n &#20491;&#25976;&#23383;&#30456;&#21152;&#30340;&#20989;&#25976;&#65292;&#24392;&#24615;&#21443;&#25976; <code>*args</code> &#22312;&#20989;&#25976;&#20316;&#29992;&#22495;&#20013;&#20854;&#23526;&#23601;&#26159;&#19968;&#20491; <code>tuple</code>&#12290;</p><pre><code>def add_n_numbers(*args):
    print(type(args))
    return sum(args)

add_n_numbers(55, 66)
add_n_numbers(55, 66, 77)
## &lt;class 'tuple'&gt;
## 121
## &lt;class 'tuple'&gt;
## 198</code></pre><p>&#33258;&#34892;&#23450;&#32681;&#20989;&#25976;&#26178;&#22914;&#26524;&#24076;&#26395;&#22238;&#20659;&#20540;&#26377;&#22810;&#20491;&#65292;&#20363;&#22914;&#19968;&#20491;&#33021;&#22816;&#23559;&#19968;&#20491;&#33521;&#25991;&#21934;&#23383;&#30340;&#20840;&#22823;&#23531;&#12289;&#20840;&#23567;&#23531;&#22806;&#22411;&#37117;&#22238;&#20659;&#30340;&#20989;&#25976;&#65292;&#21487;&#20197;&#22312; <code>return</code> &#24460;&#20197;&#36887;&#34399;&#21312;&#38548;&#20841;&#20491;&#22238;&#20659;&#20540;&#65292;&#20989;&#25976;&#20854;&#23526;&#23601;&#26159;&#22238;&#20659;&#19968;&#20491; <code>tuple</code>&#12290;</p><pre><code>def upper_lower_cases(x):
    upper_out = x.upper()
    lower_out = x.lower()
    return upper_out, lower_out

multiple_outputs = upper_lower_cases("Luke Skywalker")
print(type(multiple_outputs))
## &lt;class 'tuple'&gt;</code></pre><h2>&#23383;&#20856;</h2><p>&#23383;&#20856; <code>dict</code> &#39015;&#21517;&#24605;&#32681;&#23601;&#26159; dictionary &#30340;&#32302;&#23531;&#65292;&#36889;&#31278;&#36039;&#26009;&#32080;&#27083;&#38500;&#20102;&#20786;&#23384;&#36039;&#26009;&#65288;Values&#65289;&#20197;&#22806;&#65292;&#36996;&#21478;&#22806;&#21033;&#29992;&#37749;&#65288;Keys&#65289;&#20358;&#23565;&#36039;&#26009;&#20316;&#32034;&#24341;&#65292;&#36889;&#27171;&#30340;&#29305;&#24615;&#35731;&#25105;&#20497;&#22312;&#36984;&#25799;&#26178;&#21487;&#20197;&#20351;&#29992;&#36039;&#26009;&#30340;&#37749;&#65292;&#22914;&#27492;&#19968;&#20358;&#22312;&#38754;&#23565;&#38263;&#24230;&#24456;&#22823;&#30340;&#36039;&#26009;&#26178;&#65292;&#19981;&#38656;&#35201;&#32791;&#26178;&#35336;&#31639;&#36039;&#26009;&#25152;&#22312;&#30340;&#20301;&#32622;&#12290;&#24314;&#31435;&#30340;&#26178;&#20505;&#20351;&#29992;&#22823;&#25324;&#34399;&nbsp;<code>{}</code>&nbsp;&#23559;&#24076;&#26395;&#20786;&#23384;&#30340;&#36039;&#26009;&#21253;&#25324;&#36215;&#20358;&#65292;&#28982;&#24460;&#20998;&#21029;&#23559;&#12300;&#37749;&#12301;&#33287;&#12300;&#36039;&#26009;&#12301;&#20197; Keys &#21450; Values &#35352;&#37636;&#12290;</p><pre><code>primes_dict = {
    "1st": 2,
    "2nd": 3,
    "3rd": 5,
    "4th": 7,
    "5th": 11
}
print(type(primes_dict))
## &lt;class 'dict'&gt;</code></pre><p>&#36984;&#25799;<code>&#23383;&#20856;</code>&#20013;&#30340;&#36039;&#26009;&#25105;&#20497;&#20351;&#29992;&#20013;&#25324;&#34399;&nbsp;<code>[]</code>&nbsp;&#25645;&#37197;&#37749;&#12290;</p><pre><code>print(primes_dict["1st"])
print(primes_dict["2nd"])
print(primes_dict["3rd"])
print(primes_dict["4th"])
print(primes_dict["5th"])
## 2
## 3
## 5
## 7
## 11</code></pre><p>&#26032;&#22686;&#21487;&#20197;&#30452;&#25509;&#23459;&#21578;&nbsp;<code>dict_to_be_added["Key"] = Value</code>&#12290;</p><pre><code>primes_dict["6th"] = 13
print(primes_dict)
## {'1st': 2, '2nd': 3, '3rd': 5, '4th': 7, '5th': 11, '6th': 13}</code></pre><p>&#21034;&#38500;&#21487;&#20197;&#20351;&#29992;&#23383;&#20856;&#30340;&nbsp;<code>pop(Key, None)</code>&nbsp;&#26041;&#27861;&#23559;&#25351;&#23450;&#30340;&#12300;&#37749;&#12301;&#33287;&#12300;&#36039;&#26009;&#12301;&#32068;&#21512;&#25291;&#20986;&#65292;&#20551;&#22914;&#25214;&#19981;&#21040;&#23601;&#25291;&#20986;&nbsp;<code>None</code>&#12290;</p><pre><code>the_popped_value = primes_dict.pop("6th", None)
print(primes_dict)
## {'1st': 2, '2nd': 3, '3rd': 5, '4th': 7, '5th': 11}</code></pre><p>&#20351;&#29992;&#23383;&#20856;&#30340;&nbsp;<code>keys()</code>&nbsp;&#12289;&nbsp;<code>values()</code>&nbsp;&#33287;&nbsp;<code>items()</code>&nbsp;&#26041;&#27861;&#65292;&#21487;&#20197;&#20998;&#21029;&#21462;&#20986;&#23383;&#20856;&#20013;&#30340;&#25152;&#26377;&#30340;&#37749;&#65288;Keys&#65289;&#12289;&#25152;&#26377;&#36039;&#26009;&#65288;Values&#65289;&#20197;&#21450;&#12300;&#37749;&#12301;&#33287;&#12300;&#36039;&#26009;&#12301;&#32068;&#21512;&#65288;Items&#65289;&#12290;</p><pre><code>print(primes_dict.keys())
print(primes_dict.values())
print(primes_dict.items())
## dict_keys(['1st', '2nd', '3rd', '4th', '5th'])
## dict_values([2, 3, 5, 7, 11])
## dict_items([('1st', 2), ('2nd', 3), ('3rd', 5), ('4th', 7), ('5th', 11)])</code></pre><h2>&#38598;&#21512;</h2><p>&#38598;&#21512; <code>set</code> &#26159; Python &#20013;&#29992;&#20358;&#34389;&#29702;&#12300;&#38598;&#21512;&#36939;&#31639;&#12301;&#30340;&#36039;&#26009;&#32080;&#27083;&#65292;&#22312;&#24314;&#31435;&#30340;&#26178;&#20505;&#20351;&#29992;&#22823;&#25324;&#34399;&nbsp;<code>{}</code>&nbsp;&#23559;&#24076;&#26395;&#20786;&#23384;&#30340;&#36039;&#35338;&#21253;&#25324;&#36215;&#20358;&#65292;&#20006;&#23559;&#24076;&#26395;&#23384;&#25918;&#30340;&#36039;&#26009;&#22411;&#21029;&#33287;&#36039;&#26009;&#32080;&#27083;&#20197;&#36887;&#34399;&#20998;&#38548;&#12290;</p><pre><code>primes_set = {2, 3, 5, 7, 11}
print(type(primes_set))
## &lt;class 'set'&gt;</code></pre><p>&#36889;&#20491;&#36039;&#26009;&#32080;&#27083;&#29992;&#20358;&#23565;&#25033;&#25976;&#23416;&#20013;&#30340;&#38598;&#21512;&#30456;&#38364;&#23450;&#29702;&#21644;&#25805;&#20316;&#65292;&#25152;&#20197;&#20854;&#20013;&#21482;&#20786;&#23384;&#29544;&#19968;&#30340;&#36039;&#26009;&#65292;&#33509;&#36664;&#20837;&#22810;&#31558;&#37325;&#35079;&#36039;&#26009;&#65292;&#21063;&#26371;&#35352;&#37636;&#19968;&#31558;&#29544;&#19968;&#20540;&#65292;&#20006;&#19988;&#26159;&#19968;&#31278;&#12300;&#28961;&#24207;&#12301;&#30340;&#32080;&#27083;&#65292;&#20786;&#23384;&#22312;&#20854;&#20013;&#30340;&#36039;&#26009;&#36319;&#24314;&#31435;&#26178;&#30340;&#38918;&#24207;&#24615;&#27794;&#26377;&#38364;&#32879;&#65292;&#21487;&#33021;&#26371;&#22312;&#25805;&#20316;&#24460;&#26356;&#21205;&#38918;&#24207;&#65292;&#20294;&#36889;&#20006;&#28961;&#22823;&#31001;&#65292;&#22240;&#28858;&#38598;&#21512;&#20006;&#19981;&#25903;&#25588;&#32034;&#24341;&#65292;&#28961;&#24207;&#36889;&#20491;&#29305;&#24615;&#20063;&#19981;&#26371;&#24433;&#38911;&#38598;&#21512;&#30456;&#38364;&#23450;&#29702;&#21644;&#25805;&#20316;&#12290;</p><p>&#22522;&#30990;&#30340;&#38598;&#21512;&#25805;&#20316;&#26377;&#22235;&#20491;&#65306;</p><ol><li><p>&#20132;&#38598;&#65288;Intersection&#65289;</p></li><li><p>&#32879;&#38598;&#65288;Union&#65289;</p></li><li><p>&#24046;&#38598;&#65288;Difference&#65289;</p></li><li><p>&#23565;&#31281;&#24046;&#38598;&#65288;Symmetric difference&#65289;</p></li></ol><p>&#19978;&#36848;&#36889;&#22235;&#20491;&#22522;&#30990;&#38598;&#21512;&#25805;&#20316;&#37117;&#33021;&#22816;&#36879;&#36942;&#21628;&#21483;&#38598;&#21512;&#30340;&#26041;&#27861;&#23526;&#20316;&#65292;&#20854;&#20013;&#21482;&#26377;&#24046;&#38598;&#27794;&#26377;&#20132;&#25563;&#24459;&#65288;&#22914;&#21516;&#28187;&#27861;&#25110;&#32773;&#38500;&#27861;&#19968;&#33324;&#65289;&#65292;&#21478;&#22806;&#19977;&#32773;&#37117;&#20855;&#26377;&#20132;&#25563;&#24459;&#65288;&#22914;&#21516;&#21152;&#27861;&#25110;&#32773;&#20056;&#27861;&#19968;&#33324;&#65289;&#65292;&#36889;&#20123;&#26041;&#27861;&#37117;&#25505;&#29992;&#20197;&#22238;&#20659;&#20540;&#36664;&#20986;&#30340;&#27231;&#21046;&#12290;</p><pre><code>primes_set = {2, 3, 5, 7, 11}
odds_set = {1, 3, 5, 7, 9}
print(primes_set.intersection(odds_set))
print(primes_set.union(odds_set))
print(primes_set.difference(odds_set))
print(odds_set.difference(primes_set))
print(primes_set.symmetric_difference(odds_set))
## {3, 5, 7}
## {1, 2, 3, 5, 7, 9, 11}
## {2, 11}
## {1, 9}
## {1, 2, 9, 11}</code></pre><p>&#22312;&#35469;&#35672;&#20102;&#36039;&#26009;&#32080;&#27083;&#20043;&#24460;&#65292;&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;&#31532;&#21313;&#22235;&#36913;&#20358;&#21040;&#23614;&#32882;&#65292;&#24076;&#26395;&#24744;&#20063;&#21644;&#25105;&#19968;&#27171;&#26399;&#24453;&#19979;&#19968;&#31687;&#25991;&#31456;&#12290;</p><h2>&#24310;&#20280;&#38321;&#35712;</h2><ol><li><p><a href="https://docs.python.org/3/tutorial/datastructures.html">https://docs.python.org/3/tutorial/datastructures.html</a></p></li></ol><div><hr></div><p>&#23565;&#26044;&#36889;&#31687;&#25991;&#31456;&#26377;&#20160;&#40636;&#24819;&#27861;&#21602;&#65311;&#21916;&#27489;&#128571;&#12289;&#30041;&#35328;&#128587;&#8205;&#9794;&#65039;&#25110;&#32773;&#20998;&#20139;&#128588;</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://datainpoint.substack.com/p/week-fourteen-data-structures-in-python/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://datainpoint.substack.com/p/week-fourteen-data-structures-in-python/comments"><span>Leave a comment</span></a></p>]]></content:encoded></item><item><title><![CDATA[約維安計畫：Python 的資料型別]]></title><description><![CDATA[&#31532;&#21313;&#19977;&#36913;&#12290;]]></description><link>https://datainpoint.substack.com/p/week-thirteen-functions-and-data-types-in-python</link><guid isPermaLink="false">https://datainpoint.substack.com/p/week-thirteen-functions-and-data-types-in-python</guid><dc:creator><![CDATA[Yao-Jen Kuo]]></dc:creator><pubDate>Wed, 11 Aug 2021 07:42:05 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!lGnX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe852d231-bded-427a-9673-307f3fed2339_480x480.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!lGnX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe852d231-bded-427a-9673-307f3fed2339_480x480.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!lGnX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe852d231-bded-427a-9673-307f3fed2339_480x480.gif 424w, https://substackcdn.com/image/fetch/$s_!lGnX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe852d231-bded-427a-9673-307f3fed2339_480x480.gif 848w, https://substackcdn.com/image/fetch/$s_!lGnX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe852d231-bded-427a-9673-307f3fed2339_480x480.gif 1272w, https://substackcdn.com/image/fetch/$s_!lGnX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe852d231-bded-427a-9673-307f3fed2339_480x480.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!lGnX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe852d231-bded-427a-9673-307f3fed2339_480x480.gif" width="480" height="480" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/e852d231-bded-427a-9673-307f3fed2339_480x480.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:480,&quot;width&quot;:480,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1386492,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!lGnX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe852d231-bded-427a-9673-307f3fed2339_480x480.gif 424w, https://substackcdn.com/image/fetch/$s_!lGnX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe852d231-bded-427a-9673-307f3fed2339_480x480.gif 848w, https://substackcdn.com/image/fetch/$s_!lGnX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe852d231-bded-427a-9673-307f3fed2339_480x480.gif 1272w, https://substackcdn.com/image/fetch/$s_!lGnX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe852d231-bded-427a-9673-307f3fed2339_480x480.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#20358;&#28304;&#65306;giphy.com</figcaption></figure></div><h2>&#35299;&#26512;&#21704;&#22217;&#19990;&#30028;</h2><p>&#22312;<a href="https://datainpoint.substack.com/p/week-twelve-getting-started-with-python">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;&#31532;&#21313;&#20108;&#36913;</a>&#25105;&#20497;&#36879;&#36942; <code>print("Hello, World!") &#20358;</code>&#30906;&#35469; Python &#30340;&#38283;&#30332;&#29872;&#22659;&#21450;&#22519;&#34892;&#29872;&#22659;&#26159;&#21542;&#24050;&#32147;&#23433;&#35037;&#22949;&#30070;&#65292;&#22312;&#36889;&#19968;&#27573;&#21704;&#22217;&#19990;&#30028;&#30340;&#31243;&#24335;&#30908;&#20013;&#65292;&#20854;&#23526;&#23601;&#33021;&#39636;&#39511;&#31243;&#24335;&#35373;&#35336;&#33287;&#36039;&#26009;&#20998;&#26512;&#30340;&#19968;&#20491;&#26680;&#24515;&#31934;&#31070;&#65306;&#23565;&#36039;&#26009;&#25033;&#29992;&#20989;&#25976;&#12290;</p><p><code>print</code> &#26159;&#20989;&#25976;&#30340;&#21517;&#31281;&#65292;<code>print()</code> &#21063;&#34920;&#31034;&#35201;&#25033;&#29992;&#35442;&#20989;&#25976;&#30340;&#21151;&#33021;&#65292;&#32780; <code>&#8220;Hello, World!&#8220;</code> &#21063;&#26159;&#19968;&#20491;&#34987;&#31281;&#21628;&#28858;&#23383;&#20018;&#65288;String&#65289;&#30340;&#36039;&#26009;&#22411;&#21029;&#65307;&#25563;&#35328;&#20043;&#65292;&#21704;&#22217;&#19990;&#30028;&#21487;&#20197;&#34920;&#36948;&#28858;&#65306;&#23565; <code>&#8220;Hello, World!&#8220;</code> &#36889;&#20491;&#23383;&#20018;&#25033;&#29992;&#20102; <code>print</code> &#20989;&#25976;&#12290; </p><pre><code><code>print("Hello, World!")
## Hello, World!</code></code></pre><h2>&#20160;&#40636;&#26159;&#20989;&#25976;</h2><p>&#20989;&#25976;&#26159;&#27083;&#25104;&#25152;&#26377;&#31243;&#24335;&#35486;&#35328;&#30340;&#22522;&#26412;&#35201;&#32032;&#65292;&#19968;&#20491;&#20989;&#25976;&#26159;&#19968;&#27573;&#12300;&#34987;&#21629;&#21517;&#12301;&#30340;&#31243;&#24335;&#30908;&#65292;&#36889;&#27573;&#31243;&#24335;&#30908;&#21487;&#20197;&#29992;&#26044;&#22519;&#34892;&#26576;&#20491;&#29305;&#23450;&#20219;&#21209;&#65292;&#21487;&#8230;</p>
      <p>
          <a href="https://datainpoint.substack.com/p/week-thirteen-functions-and-data-types-in-python">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[約維安計畫：Python 起步走]]></title><description><![CDATA[&#31532;&#21313;&#20108;&#36913;&#12290;]]></description><link>https://datainpoint.substack.com/p/week-twelve-getting-started-with-python</link><guid isPermaLink="false">https://datainpoint.substack.com/p/week-twelve-getting-started-with-python</guid><dc:creator><![CDATA[Yao-Jen Kuo]]></dc:creator><pubDate>Tue, 03 Aug 2021 01:46:24 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!CPG9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0920174-8f41-4826-847b-c0b325b5e0cf_480x476.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!CPG9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0920174-8f41-4826-847b-c0b325b5e0cf_480x476.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!CPG9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0920174-8f41-4826-847b-c0b325b5e0cf_480x476.gif 424w, https://substackcdn.com/image/fetch/$s_!CPG9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0920174-8f41-4826-847b-c0b325b5e0cf_480x476.gif 848w, https://substackcdn.com/image/fetch/$s_!CPG9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0920174-8f41-4826-847b-c0b325b5e0cf_480x476.gif 1272w, https://substackcdn.com/image/fetch/$s_!CPG9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0920174-8f41-4826-847b-c0b325b5e0cf_480x476.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!CPG9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0920174-8f41-4826-847b-c0b325b5e0cf_480x476.gif" width="480" height="476" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/c0920174-8f41-4826-847b-c0b325b5e0cf_480x476.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:476,&quot;width&quot;:480,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:29424,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!CPG9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0920174-8f41-4826-847b-c0b325b5e0cf_480x476.gif 424w, https://substackcdn.com/image/fetch/$s_!CPG9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0920174-8f41-4826-847b-c0b325b5e0cf_480x476.gif 848w, https://substackcdn.com/image/fetch/$s_!CPG9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0920174-8f41-4826-847b-c0b325b5e0cf_480x476.gif 1272w, https://substackcdn.com/image/fetch/$s_!CPG9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0920174-8f41-4826-847b-c0b325b5e0cf_480x476.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#20358;&#28304;&#65306;giphy.com</figcaption></figure></div><blockquote><p>Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python&#8217;s elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.</p></blockquote><p>Python &#26159;&#19968;&#31278;&#24291;&#27867;&#29992;&#36884;&#31243;&#24335;&#35486;&#35328;&#65288;General-purposed programming language&#65289;&#65292;&#20855;&#26377;&#39640;&#38542;&#12289;&#30452;&#35695;&#12289;&#33287;&#31777;&#28500;&#30340;&#29305;&#24615;&#65292;&#30001;&#33655;&#34349;&#38651;&#33126;&#31185;&#23416;&#23478; Guido van Rossum &#26044; 1991 &#24180;&#21109;&#36896;&#65292;&#30446;&#21069;&#30001;&nbsp;<a href="https://www.python.org/">Python &#36575;&#39636;&#22522;&#37329;&#26371;</a>&#32173;&#35703;&#12290;Python &#22312;&#36039;&#26009;&#31185;&#23416;&#12289;&#32178;&#31449;&#38283;&#30332;&#33287;&#31995;&#32113;&#33258;&#21205;&#21270;&#31561;&#25033;&#29992;&#38936;&#22495;&#20013;&#20493;&#21463;&#29105;&#24859;&#65292;&#20840;&#29699;&#30693;&#21517;&#20844;&#21496;&#20687;&nbsp;<a href="https://www.pixar.com/">Pixar</a>&nbsp;&#29992;&#26044;&#38651;&#24433;&#35069;&#20316;&#12289;<a href="https://www.twitch.tv/">Twitch</a>&nbsp;&#29992;&#26044;&#31995;&#32113;&#24314;&#32622;&#20197;&#21450;&nbsp;<a href="https://www.spotify.com/">Spotify</a>&nbsp;&#29992;&#26044;&#25512;&#34214;&#27468;&#26354;&#12290;&#22312; NumPy&#12289;SciPy&#12289;Pandas&#12289;Matplotlib&#12289;Scikit-Learn&#12289;TensorFlow &#33287; PyTorch &#31561;&#22871;&#20214;&#30340;&#24375;&#21147;&#21152;&#25345;&#19979; Python &#25104;&#28858;&#19990;&#30028;&#21508;&#22320;&#36039;&#26009;&#31185;&#23416;&#22296;&#38538;&#30340;&#39318;&#36984;&#65292;&#22296;&#38538;&#35041;&#30340;&#36039;&#26009;&#31185;&#23416;&#23478;&#20351;&#29992; Python &#24478;&#36039;&#26009;&#20013;&#25366;&#25496;&#29305;&#24501;&#23563;&#25214;&#27934;&#35211;&#65288;Insight&#65289;&#12289;&#36039;&#26009;&#24037;&#31243;&#24107;&#20351;&#29992; Python &#24314;&#27083;&#33287;&#37096;&#32626;&#27231;&#22120;&#23416;&#32722;&#33287;&#33258;&#21205;&#21270;&#31995;&#32113;&#65292;&#28858;&#20225;&#26989;&#29554;&#21462;&#31478;&#29229;&#20778;&#21218;&#12290;</p><h2>&#39514;&#20154;&#30340;&#21463;&#27489;&#36814;&#31243;&#24230;</h2><p>&#25130;&#33267; 2021 &#24180; 7 &#26376;&#65292;Python &#22312; TIOBE Index &#25490;&#21517;&#31532; 3 &#20301;&#12289;&#22312; 2020 IEEE Top Programming Languages &#35519;&#26597;&#25490;&#21517;&#31532; 1 &#20301;&#12289;&#22312; StackOverflow Trends &#20197; 16% &#21839;&#38988;&#27604;&#29575;&#25490;&#21517;&#31532; 1 &#20301;&#65307;&#26681;&#25818;&#36039;&#26009;&#31185;&#23416;&#23478;&#31038;&#32676; Kaggle &#22312; 2020 &#24180;&#37341;&#23565;&#32178;&#31449;&#26371;&#21729;&#25152;&#30332;&#20986;&#30340;&#21839;&#21367;&#65292;Python &#22312;&#36039;&#26009;&#31185;&#23416;&#23478;&#26085;&#24120;&#38971;&#32321;&#20351;&#29992;&#35486;&#35328;&#20013;&#25490;&#21517;&#31532;&#19968;&#65292;&#23565;&#26044;&#25216;&#33021;&#32068;&#21512;&#28085;&#33995;&#36039;&#26009;&#31185;&#23416;&#33287;&#36575;&#39636;&#24037;&#31243;&#30340;&#32004;&#32173;&#23433;&#32780;&#35328;&#65292;&#23416;&#32722; Python &#30340;&#37325;&#35201;&#24615;&#19981;&#35328;&#21487;&#21947;&#12290;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!a4ZA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0b8e924-c241-4ef3-a899-2df6bcb9a9b3_1918x1226.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!a4ZA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0b8e924-c241-4ef3-a899-2df6bcb9a9b3_1918x1226.png 424w, https://substackcdn.com/image/fetch/$s_!a4ZA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0b8e924-c241-4ef3-a899-2df6bcb9a9b3_1918x1226.png 848w, https://substackcdn.com/image/fetch/$s_!a4ZA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0b8e924-c241-4ef3-a899-2df6bcb9a9b3_1918x1226.png 1272w, https://substackcdn.com/image/fetch/$s_!a4ZA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0b8e924-c241-4ef3-a899-2df6bcb9a9b3_1918x1226.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!a4ZA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0b8e924-c241-4ef3-a899-2df6bcb9a9b3_1918x1226.png" width="1456" height="931" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/b0b8e924-c241-4ef3-a899-2df6bcb9a9b3_1918x1226.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:931,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:389887,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!a4ZA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0b8e924-c241-4ef3-a899-2df6bcb9a9b3_1918x1226.png 424w, https://substackcdn.com/image/fetch/$s_!a4ZA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0b8e924-c241-4ef3-a899-2df6bcb9a9b3_1918x1226.png 848w, https://substackcdn.com/image/fetch/$s_!a4ZA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0b8e924-c241-4ef3-a899-2df6bcb9a9b3_1918x1226.png 1272w, https://substackcdn.com/image/fetch/$s_!a4ZA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0b8e924-c241-4ef3-a899-2df6bcb9a9b3_1918x1226.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#22312; TIOBE Index &#25490;&#21517;&#31532; 3 &#20301;</figcaption></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5Kv6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7db64478-915d-4d9a-ab30-9696caedb994_1976x2292.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5Kv6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7db64478-915d-4d9a-ab30-9696caedb994_1976x2292.png 424w, https://substackcdn.com/image/fetch/$s_!5Kv6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7db64478-915d-4d9a-ab30-9696caedb994_1976x2292.png 848w, https://substackcdn.com/image/fetch/$s_!5Kv6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7db64478-915d-4d9a-ab30-9696caedb994_1976x2292.png 1272w, https://substackcdn.com/image/fetch/$s_!5Kv6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7db64478-915d-4d9a-ab30-9696caedb994_1976x2292.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5Kv6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7db64478-915d-4d9a-ab30-9696caedb994_1976x2292.png" width="1456" height="1689" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/7db64478-915d-4d9a-ab30-9696caedb994_1976x2292.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1689,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:340470,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!5Kv6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7db64478-915d-4d9a-ab30-9696caedb994_1976x2292.png 424w, https://substackcdn.com/image/fetch/$s_!5Kv6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7db64478-915d-4d9a-ab30-9696caedb994_1976x2292.png 848w, https://substackcdn.com/image/fetch/$s_!5Kv6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7db64478-915d-4d9a-ab30-9696caedb994_1976x2292.png 1272w, https://substackcdn.com/image/fetch/$s_!5Kv6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7db64478-915d-4d9a-ab30-9696caedb994_1976x2292.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#22312; 2020 IEEE Top Programming Languages &#35519;&#26597;&#25490;&#21517;&#31532; 1 &#20301;</figcaption></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!e8SN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6692d7b-2e4b-4d49-ad67-b927812d5890_1316x852.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!e8SN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6692d7b-2e4b-4d49-ad67-b927812d5890_1316x852.png 424w, https://substackcdn.com/image/fetch/$s_!e8SN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6692d7b-2e4b-4d49-ad67-b927812d5890_1316x852.png 848w, https://substackcdn.com/image/fetch/$s_!e8SN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6692d7b-2e4b-4d49-ad67-b927812d5890_1316x852.png 1272w, https://substackcdn.com/image/fetch/$s_!e8SN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6692d7b-2e4b-4d49-ad67-b927812d5890_1316x852.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!e8SN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6692d7b-2e4b-4d49-ad67-b927812d5890_1316x852.png" width="1316" height="852" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/a6692d7b-2e4b-4d49-ad67-b927812d5890_1316x852.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:852,&quot;width&quot;:1316,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:278169,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!e8SN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6692d7b-2e4b-4d49-ad67-b927812d5890_1316x852.png 424w, https://substackcdn.com/image/fetch/$s_!e8SN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6692d7b-2e4b-4d49-ad67-b927812d5890_1316x852.png 848w, https://substackcdn.com/image/fetch/$s_!e8SN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6692d7b-2e4b-4d49-ad67-b927812d5890_1316x852.png 1272w, https://substackcdn.com/image/fetch/$s_!e8SN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6692d7b-2e4b-4d49-ad67-b927812d5890_1316x852.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#22312; StackOverflow Trends &#20197; 16% &#21839;&#38988;&#27604;&#29575;&#25490;&#21517;&#31532; 1 &#20301;</figcaption></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zidL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F009933ed-af9e-4d2d-a562-7e49e1e8fd35_1864x1202.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zidL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F009933ed-af9e-4d2d-a562-7e49e1e8fd35_1864x1202.png 424w, https://substackcdn.com/image/fetch/$s_!zidL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F009933ed-af9e-4d2d-a562-7e49e1e8fd35_1864x1202.png 848w, https://substackcdn.com/image/fetch/$s_!zidL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F009933ed-af9e-4d2d-a562-7e49e1e8fd35_1864x1202.png 1272w, https://substackcdn.com/image/fetch/$s_!zidL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F009933ed-af9e-4d2d-a562-7e49e1e8fd35_1864x1202.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zidL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F009933ed-af9e-4d2d-a562-7e49e1e8fd35_1864x1202.png" width="1456" height="939" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/009933ed-af9e-4d2d-a562-7e49e1e8fd35_1864x1202.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:939,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:138978,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!zidL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F009933ed-af9e-4d2d-a562-7e49e1e8fd35_1864x1202.png 424w, https://substackcdn.com/image/fetch/$s_!zidL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F009933ed-af9e-4d2d-a562-7e49e1e8fd35_1864x1202.png 848w, https://substackcdn.com/image/fetch/$s_!zidL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F009933ed-af9e-4d2d-a562-7e49e1e8fd35_1864x1202.png 1272w, https://substackcdn.com/image/fetch/$s_!zidL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F009933ed-af9e-4d2d-a562-7e49e1e8fd35_1864x1202.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#22312; 2020 Kaggle ML&amp;DS Survey &#36039;&#26009;&#31185;&#23416;&#23478;&#26085;&#24120;&#38971;&#32321;&#20351;&#29992;&#35486;&#35328;&#20013;&#25490;&#21517;&#31532;&#19968;</figcaption></figure></div><h2>Python &#39080;&#26684;&#25351;&#21335;</h2><p>&#39080;&#26684;&#25351;&#21335;&#65288;Style guide&#65289;&#25351;&#30340;&#26159;&#19968;&#22871;&#35215;&#31684;&#31243;&#24335;&#35486;&#35328;&#22312;&#23531;&#20316;&#26178;&#24517;&#38920;&#36981;&#23432;&#30340;&#32232;&#25490;&#12289;&#26684;&#24335;&#21644;&#35373;&#35336;&#30340;&#28310;&#21063;&#65292;&#36981;&#24478;&#39080;&#26684;&#25351;&#21335;&#33021;&#22816;&#30906;&#20445;&#27599;&#19968;&#27573;&#31243;&#24335;&#30908;&#37117;&#21644;&#20854;&#20182;&#19981;&#21516;&#20154;&#23531;&#20316;&#30340;&#31243;&#24335;&#30908;&#26377;&#39640;&#24230;&#19968;&#33268;&#24615;&#65292;&#34987;&#30526;&#22810;&#20351;&#29992;&#32773;&#25505;&#29992;&#30340; Python &#39080;&#26684;&#25351;&#21335;&#26159;&#23448;&#26041;&#30340; Python &#25913;&#36914;&#25552;&#26696;&#65288;Python Enhancement Proposals, PEPs&#65289;&#31532;&#20843;&#38917;&#65306;<a href="https://www.python.org/dev/peps/pep-0008">https://www.python.org/dev/peps/pep-0008</a>&#65292;&#32004;&#32173;&#23433;&#35336;&#30059;&#20063;&#21516;&#27171;&#36981;&#24490; Python &#25913;&#36914;&#25552;&#26696;&#31532;&#20843;&#38917;&#65292;&#20854;&#20013;&#20540;&#24471;&#27880;&#24847;&#30340;&#24190;&#20491;&#37325;&#40670;&#26377;&#65306;</p><ul><li><p><strong>&#32302;&#25490;&#20351;&#29992;&#22235;&#20491;&#31354;&#26684;</strong>&#65292;&#19981;&#21516;&#26044;&#22810;&#25976;&#30340;&#31243;&#24335;&#35486;&#35328;&#20351;&#29992;&#19968;&#23565;&#22823;&#25324;&#34399;&#65288;A curly-brace pair&#65289;&#23559;&#25944;&#36848;&#21253;&#35037;&#24418;&#25104;&#31243;&#24335;&#21312;&#22602;&#65288;Code blocks&#65289;&#65292;Python &#20351;&#29992;&#32302;&#25490;&#65288;Indentations&#65289;&#23559;&#25944;&#36848;&#21253;&#35037;&#28858;&#31243;&#24335;&#21312;&#22602;&#65292;&#22240;&#27492;&#36889;&#20491;&#39080;&#26684;&#39023;&#24471;&#26684;&#22806;&#37325;&#35201;&#12290;</p></li><li><p>&#21629;&#21517;&#30340;&#26178;&#20505;&#20351;&#29992;<strong>&#20840;&#23567;&#23531;&#33521;&#25991;</strong>&#65292;&#25505;&#29992;<strong>&#34503;&#24418;&#21629;&#21517;&#27861;</strong>&#65288;Snake case&#65289;&#65292;&#19981;&#21516;&#21934;&#23383;&#20043;&#38291;&#20197;&#24213;&#32218; _ &#30456;&#38548;&#12290;</p></li><li><p>&#19981;&#33021;&#20351;&#29992;&#20445;&#30041;&#23383;&#20316;&#29289;&#20214;&#30340;&#21629;&#21517;&#65292;&#26371;&#29986;&#29983;&#37679;&#35492;&#65292;Python &#30340;&#20445;&#30041;&#23383;&#21487;&#20197;&#21443;&#32771;&#65306;<a href="https://docs.python.org/3/reference/lexical_analysis.html#keywords">https://docs.python.org/3/reference/lexical_analysis.html#keywords</a></p></li><li><p>&#20351;&#29992;<strong>&#21934;&#25976;&#21517;&#35422;</strong>&#28858;&#36039;&#26009;&#22411;&#21029;&#65288;Data types&#65289;&#23526;&#20363;&#30340;&#29289;&#20214;&#21629;&#21517;&#65292;&#20351;&#29992;<strong>&#35079;&#25976;&#21517;&#35422;</strong>&#28858;&#36039;&#26009;&#32080;&#27083;&#65288;Data structures&#65289;&#23526;&#20363;&#30340;&#29289;&#20214;&#21629;&#21517;&#65292;&#20351;&#29992;<strong>&#21205;&#35422;</strong>&#28858;&#20989;&#25976;&#65288;Functions&#65289;&#25110;&#26041;&#27861;&#65288;Methods&#65289;&#21629;&#21517;&#65292;&#30433;&#37327;&#35731;&#21517;&#31281;&#31777;&#28500;&#19988;&#20855;&#26377;&#24847;&#32681;&#12290;</p></li><li><p>&#19981;&#35201;&#20351;&#29992;&#20839;&#24314;&#20989;&#25976;&#20316;&#29289;&#20214;&#30340;&#21629;&#21517;&#65292;<strong>&#36991;&#20813;&#35206;&#33995;&#20839;&#24314;&#20989;&#25976;</strong>&#30340;&#21151;&#33021;&#65292;Python &#30340;&#20839;&#24314;&#20989;&#25976;&#21487;&#20197;&#21443;&#32771;&#65306;<a href="https://docs.python.org/3/library/functions.html">https://docs.python.org/3/library/functions.html</a>&#12290;</p></li></ul><pre><code><code># Good Python naming
taiwan_number_one = True
taiwan_number_1 = True

# Bad Python naming
taiwanNumberOne = True
Taiwan_Number_One = True
TaiwanNumberOne = True
twno1 = True
int = 87  # int() is a built-in function</code></code></pre><h2>Python &#30340;&#21704;&#22217;&#19990;&#30028;</h2><p>&#12300;&#21704;&#22217;&#19990;&#30028;&#12301;&#26159;&#27599;&#31278;&#35486;&#35328;&#26368;&#22522;&#26412;&#20063;&#26368;&#31777;&#21934;&#30340;&#31243;&#24335;&#65292;&#36890;&#24120;&#29992;&#20316;&#30906;&#35469;&#19968;&#20491;&#35486;&#35328;&#22914;&#20309;&#36939;&#20316;&#12289;&#32232;&#35695;&#22120;&#12289;&#38283;&#30332;&#29872;&#22659;&#21450;&#22519;&#34892;&#29872;&#22659;&#26159;&#21542;&#24050;&#32147;&#23433;&#35037;&#22949;&#30070;&#12290;&#35201;&#38918;&#21033;&#36939;&#34892; Python &#30340;&#21704;&#22217;&#19990;&#30028;&#20197;&#21450;&#26410;&#20358;&#30340; Python &#36039;&#26009;&#31185;&#23416;&#25033;&#29992;&#65292;&#39318;&#20808;&#35201;&#30906;&#23450;&#22312; Jupyter &#26143;&#29699;&#30340;&#20282;&#26381;&#22120;&#36984;&#38917;&#36984;&#25799;&#20102;&#12300;Data science environment&#65306;&#23416;&#32722; Python&#12289;R &#33287; Julia &#30340;&#36039;&#26009;&#31185;&#23416;&#29872;&#22659;&#12301;&#12290;</p><p>&#24536;&#35352;&#20102;&#20160;&#40636;&#26159; Jupyter &#26143;&#29699;&#21966;&#65311;&#35079;&#32722;&#19968;&#19979;<a href="https://datainpoint.substack.com/p/week-zero-welcome">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;&#31532;&#38646;&#36913;</a>&#21543;&#65281;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HMwv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HMwv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 424w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 848w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1272w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!HMwv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png" width="1456" height="964" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:964,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:137396,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!HMwv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 424w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 848w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1272w, https://substackcdn.com/image/fetch/$s_!HMwv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F03ac6c21-6181-45ed-a4e4-982fc42ea90e_1574x1042.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#36984;&#25799;&#12300;Data science environment&#65306;&#23416;&#32722; Python&#12289;R &#33287; Julia &#30340;&#36039;&#26009;&#31185;&#23416;&#29872;&#22659;&#12301;</figcaption></figure></div><p>&#20282;&#26381;&#22120;&#21855;&#21205;&#20043;&#24460;&#20358;&#21040; Jupyter &#26143;&#29699;&#30340;&#39318;&#38913;&#65292;&#22312;&#21491;&#26041; Launcher &#40670;&#36984;&#26032;&#22686;&#19968;&#20491;&#26680;&#24515;&#65288;Kernel&#65289;&#28858; Python 3 &#30340; Jupyter Notebook&#12290;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!frAS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F5fd9204f-f048-4fe0-9e33-634e13d7f6cf_1318x1238.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!frAS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F5fd9204f-f048-4fe0-9e33-634e13d7f6cf_1318x1238.png 424w, https://substackcdn.com/image/fetch/$s_!frAS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F5fd9204f-f048-4fe0-9e33-634e13d7f6cf_1318x1238.png 848w, https://substackcdn.com/image/fetch/$s_!frAS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F5fd9204f-f048-4fe0-9e33-634e13d7f6cf_1318x1238.png 1272w, https://substackcdn.com/image/fetch/$s_!frAS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F5fd9204f-f048-4fe0-9e33-634e13d7f6cf_1318x1238.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!frAS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F5fd9204f-f048-4fe0-9e33-634e13d7f6cf_1318x1238.png" width="1318" height="1238" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/5fd9204f-f048-4fe0-9e33-634e13d7f6cf_1318x1238.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1238,&quot;width&quot;:1318,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:161164,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!frAS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F5fd9204f-f048-4fe0-9e33-634e13d7f6cf_1318x1238.png 424w, https://substackcdn.com/image/fetch/$s_!frAS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F5fd9204f-f048-4fe0-9e33-634e13d7f6cf_1318x1238.png 848w, https://substackcdn.com/image/fetch/$s_!frAS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F5fd9204f-f048-4fe0-9e33-634e13d7f6cf_1318x1238.png 1272w, https://substackcdn.com/image/fetch/$s_!frAS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F5fd9204f-f048-4fe0-9e33-634e13d7f6cf_1318x1238.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#26032;&#22686;&#19968;&#20491;&#26680;&#24515;&#65288;Kernel&#65289;&#28858; Python 3 &#30340; Jupyter Notebook</figcaption></figure></div><p>&#20006;&#19988;&#22312; Jupyter Notebook &#30340;&#31532;&#19968;&#20491;&#20786;&#23384;&#26684;&#20013;&#21360;&#20986; Python &#30340;&#21704;&#22217;&#19990;&#30028;&#65306;</p><pre><code>print("Hello, World!")</code></pre><p>&#38500;&#20102; Python &#30340;&#21704;&#22217;&#19990;&#30028;&#65292;&#25105;&#20497;&#20063;&#24456;&#40723;&#21237;&#21021;&#23416;&#32773;&#33457;&#19968;&#40670;&#26178;&#38291;&#38321;&#35712; Python &#31146;&#23416;&#65288;The Zen of Python&#65289;&#65292;&#26296;&#35299;&#35373;&#35336;&#20197;&#21450;&#24859;&#22909;&#36889;&#20491;&#31243;&#24335;&#35486;&#35328;&#30340;&#20154;&#22312;&#35299;&#27770;&#21839;&#38988;&#25110;&#32773;&#38754;&#33256;&#25225;&#25799;&#30340;&#26178;&#20505;&#65292;&#22823;&#37117;&#25505;&#29992;&#20160;&#40636;&#27171;&#30340;&#20729;&#20540;&#35264;&#33287;&#24605;&#32210;&#65292;&#25105;&#26368;&#21916;&#27489;&#30340;&#19968;&#21477; Python &#31146;&#23416;&#26159;&#65306;</p><blockquote><p>Now is better than never.</p></blockquote><p>&#22312; Jupyter Notebook &#30340;&#31532;&#20108;&#20491;&#20786;&#23384;&#26684;&#20013;&#21360;&#20986; Python &#31146;&#23416;&#65306;</p><pre><code>import this</code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!UUVG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5ba689b-18ac-47d5-bff7-9fd2ef26f464_2880x1088.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!UUVG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5ba689b-18ac-47d5-bff7-9fd2ef26f464_2880x1088.png 424w, https://substackcdn.com/image/fetch/$s_!UUVG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5ba689b-18ac-47d5-bff7-9fd2ef26f464_2880x1088.png 848w, https://substackcdn.com/image/fetch/$s_!UUVG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5ba689b-18ac-47d5-bff7-9fd2ef26f464_2880x1088.png 1272w, https://substackcdn.com/image/fetch/$s_!UUVG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5ba689b-18ac-47d5-bff7-9fd2ef26f464_2880x1088.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!UUVG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5ba689b-18ac-47d5-bff7-9fd2ef26f464_2880x1088.png" width="1456" height="550" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/e5ba689b-18ac-47d5-bff7-9fd2ef26f464_2880x1088.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:550,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:311331,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!UUVG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5ba689b-18ac-47d5-bff7-9fd2ef26f464_2880x1088.png 424w, https://substackcdn.com/image/fetch/$s_!UUVG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5ba689b-18ac-47d5-bff7-9fd2ef26f464_2880x1088.png 848w, https://substackcdn.com/image/fetch/$s_!UUVG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5ba689b-18ac-47d5-bff7-9fd2ef26f464_2880x1088.png 1272w, https://substackcdn.com/image/fetch/$s_!UUVG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5ba689b-18ac-47d5-bff7-9fd2ef26f464_2880x1088.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>&#22823;&#21151;&#21578;&#25104;&#65292;&#22312;&#38918;&#21033;&#22519;&#34892;&#20102; Python &#30340;&#21704;&#22217;&#19990;&#30028;&#20197;&#21450; Python &#31146;&#23416;&#20043;&#24460;&#65292;&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;&#31532;&#21313;&#20108;&#36913;&#20358;&#21040;&#23614;&#32882;&#65292;&#24076;&#26395;&#24744;&#20063;&#21644;&#25105;&#19968;&#27171;&#26399;&#24453;&#19979;&#19968;&#31687;&#25991;&#31456;&#12290;</p><div><hr></div><p>&#19981;&#30693;&#36947;&#21508;&#20301;&#38321;&#35712;&#23436; Python &#31146;&#23416;&#20043;&#24460;&#26368;&#21916;&#27489;&#30340;&#26159;&#21738;&#19968;&#21477;&#65311;&#35531;&#22519;&#34892; <code>import this</code> &#36942;&#24460;&#30340;&#20013;&#32026;&#32004;&#32173;&#23433;&#22312;&#36889;&#31687;&#25991;&#31456;&#30041;&#35328;&#22238;&#35206;<strong>&#128587;</strong>&#36319;&#25105;&#20497;&#20998;&#20139;&#20320;&#26368;&#21916;&#27489;&#30340;&#19968;&#21477; Python &#31146;&#23416;&#128571;</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://datainpoint.substack.com/p/week-twelve-getting-started-with-python/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://datainpoint.substack.com/p/week-twelve-getting-started-with-python/comments"><span>Leave a comment</span></a></p>]]></content:encoded></item><item><title><![CDATA[約維安計畫：中級約維安的第一個里程碑專案]]></title><description><![CDATA[&#31532;&#21313;&#19968;&#36913;&#12290;]]></description><link>https://datainpoint.substack.com/p/week-eleven-milestone-project</link><guid isPermaLink="false">https://datainpoint.substack.com/p/week-eleven-milestone-project</guid><dc:creator><![CDATA[Yao-Jen Kuo]]></dc:creator><pubDate>Thu, 22 Jul 2021 10:56:05 GMT</pubDate><enclosure url="https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/fb331340-cb51-442c-b8da-43852ae7363f_480x270.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!nE3z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F13c77d23-9fd7-47aa-bf8e-c7c5d013a8e6_480x270.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nE3z!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F13c77d23-9fd7-47aa-bf8e-c7c5d013a8e6_480x270.gif 424w, https://substackcdn.com/image/fetch/$s_!nE3z!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F13c77d23-9fd7-47aa-bf8e-c7c5d013a8e6_480x270.gif 848w, https://substackcdn.com/image/fetch/$s_!nE3z!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F13c77d23-9fd7-47aa-bf8e-c7c5d013a8e6_480x270.gif 1272w, https://substackcdn.com/image/fetch/$s_!nE3z!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F13c77d23-9fd7-47aa-bf8e-c7c5d013a8e6_480x270.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!nE3z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F13c77d23-9fd7-47aa-bf8e-c7c5d013a8e6_480x270.gif" width="480" height="270" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/13c77d23-9fd7-47aa-bf8e-c7c5d013a8e6_480x270.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:270,&quot;width&quot;:480,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:3076270,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!nE3z!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F13c77d23-9fd7-47aa-bf8e-c7c5d013a8e6_480x270.gif 424w, https://substackcdn.com/image/fetch/$s_!nE3z!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F13c77d23-9fd7-47aa-bf8e-c7c5d013a8e6_480x270.gif 848w, https://substackcdn.com/image/fetch/$s_!nE3z!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F13c77d23-9fd7-47aa-bf8e-c7c5d013a8e6_480x270.gif 1272w, https://substackcdn.com/image/fetch/$s_!nE3z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F13c77d23-9fd7-47aa-bf8e-c7c5d013a8e6_480x270.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">&#20358;&#28304;&#65306;giphy.com</figcaption></figure></div><p>&#32004;&#32173;&#23433;&#35336;&#30059;&#21363;&#23559;&#36814;&#20358;&#31532;&#20108;&#20491;&#37324;&#31243;&#30865;&#23560;&#26696;&#65281;&#24478;&#31532;&#20845;&#36913;&#21040;&#31532;&#21313;&#36913;&#65292;&#25105;&#20497;&#24478;&#26412;&#27231;&#31471;&#30340;&#23416;&#32722;&#29872;&#22659;&#21040; SQL &#30340;&#36914;&#38542;&#26597;&#35426;&#65292;&#26296;&#35299;&#22914;&#20309;&#22312; Jupyter &#26143;&#29699;&#23416;&#32722;&#20006;&#19988;&#32244;&#32722; SQL&#12290;</p><p>&#24536;&#35352;&#20102;&#20160;&#40636;&#26159; SQL &#21966;&#65311;&#19981;&#35201;&#32202;&#65292;&#36879;&#36942;&#36889;&#20491;&#37324;&#31243;&#30865;&#23560;&#26696;&#65292;&#27491;&#26159;&#35731;&#25105;&#20497;&#35079;&#32722;&#19968;&#19979;&#36889;&#20116;&#36913;&#23416;&#32722;&#25991;&#31456;&#30340;&#22909;&#27231;&#26371;&#65281;</p><ol><li><p><a href="https://datainpoint.substack.com/p/week-six-local-environment?r=8zju4&amp;utm_campaign=post&amp;utm_medium=web&amp;utm_source=copy">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;&#31532;&#20845;&#36913; | &#26412;&#27231;&#31471;&#30340;&#23416;&#32722;&#29872;&#22659;</a>&#12290;</p></li><li><p><a href="https://datainpoint.substack.com/p/week-seven-getting-started-with-sql?r=8zju4&amp;utm_campaign=post&amp;utm_medium=web&amp;utm_source=copy">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;&#31532;&#19971;&#36913; | SQL &#36215;&#27493;&#36208;</a>&#12290;</p></li><li><p><a href="https://datainpoint.substack.com/p/week-nine-intermediate-sql?r=8zju4&amp;utm_campaign=post&amp;utm_medium=web&amp;utm_source=copy">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;&#31532;&#20843;&#36913; | SQL &#30340;&#22522;&#30990;&#26597;&#35426;</a>&#12290;</p></li><li><p><a href="https://datainpoint.substack.com/p/week-nine-intermediate-sql?r=8zju4&amp;utm_campaign=post&amp;utm_medium=web&amp;utm_source=copy">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;&#31532;&#20061;&#36913; | SQL &#30340;&#20013;&#38542;&#26597;&#35426;</a>&#12290;</p></li><li><p><a href="https://datainpoint.substack.com/p/week-ten-advanced-sql?r=8zju4&amp;utm_campaign=post&amp;utm_medium=web&amp;utm_source=copy">&#32004;&#32173;&#23433;&#35336;&#30059;&#65306;&#31532;&#21313;&#36913; | SQL &#30340;&#36914;&#38542;&#26597;&#35426;</a>&#12290;</p></li></ol><h2>&#37324;&#31243;&#30865;&#23560;&#26696;</h2><p>&#40670;&#25802;&#31532;&#21313;&#19968;&#36913;&#30340;&#36039;&#26009;&#22846;&#36899;&#32080;&#65306;<a href="https://lab.datainpoint.com/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fdatainpoint%2Fweek-eleven-milestone-project&amp;urlpath=tree%2Fweek-eleven-milestone-project%2F&amp;branch=main">&#31532;&#21313;&#19968;&#36913;&#30340;&#23560;&#26696;&#36039;&#26009;&#22846;</a>&#12290;</p><p>&#40670;&#25802;&#36899;&#32080;&#20043;&#24460;&#23559;&#26371;&#35079;&#35069;&#19968;&#20221;&#23560;&#26696;&#36039;&#26009;&#22846;&#21040; Jupyter &#26143;&#29699;&#30340;&#39318;&#38913;&#65292;&#38283;&#21855;&#36889;&#20491;&#36039;&#26009;&#22846;&#25105;&#20497;&#21487;&#20197;&#30475;&#21040;&#20116;&#20491;&#27284;&#26696;&#65306;</p><ul><li><p>README.md</p></li><li><p>notebook.ipynb</p></li><li><p>exercise&#8230;</p></li></ul>
      <p>
          <a href="https://datainpoint.substack.com/p/week-eleven-milestone-project">
              Read more
          </a>
      </p>
   ]]></content:encoded></item></channel></rss>