<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3822675434782806040</id><updated>2026-09-28T09:54:05.097-07:00</updated><category term="android memo"/><category term="python"/><category term="APP"/><category term="android studio"/><category term="java"/><category term="andro易d"/><category term="SpeedBrain"/><category term="人工智能"/><category term="壁紙，桌布"/><category term="物連網"/><category term="EXCEL VBA"/><category term="Talking Note"/><category term="auto redialer"/><category term="game"/><category term="tools"/><category term="ubuntu"/><category term="終極記牌大師"/><category term="自動重撥"/><category term="針灸"/><category term="針道"/><title type='text'>2D狂想</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>99</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-2970213057364565885</id><published>2021-09-11T18:09:00.002-07:00</published><updated>2021-09-11T18:09:10.989-07:00</updated><title type='text'>Privacy Policy</title><content type='html'>&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;b&gt;Privacy Policy&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;thujmb built the comp.android.speedBrain app as a Free app. This SERVICE is provided by thujmb at no cost and is intended for use as is.&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;This page is used to inform visitors regarding my policies with the collection&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; use&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; and disclosure of Personal Information if anyone decided to use my Service.&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;If you choose to use my Service&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; then you agree to the collection and use of information in relation to this policy. The Personal Information that I collect is used for providing and improving the Service. I will not use or share your information with anyone except as described in this Privacy Policy.&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; which is accessible at comp.android.speedBrain unless otherwise defined in this Privacy Policy.&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;b&gt;Information Collection and Use&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;For a better experience&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; while using our Service&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; I may require you to provide us with certain personally identifiable information&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; including but not limited to local storage&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; google plaly game singin&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; . The information that I request will be retained on your device and is not collected by me in any way.&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;The app does use third party services that may collect information used to identify you.&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;Link to privacy policy of third party service providers used by the app&lt;/p&gt;&lt;ul class=&quot;ul1&quot;&gt;&lt;li class=&quot;li2&quot; style=&quot;color: #e4af0a; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;span class=&quot;s2&quot; style=&quot;color: #454545; font-family: Menlo; font-size: 10px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&lt;a href=&quot;https://www.google.com/policies/privacy/&quot;&gt;&lt;span class=&quot;s3&quot; style=&quot;color: #e4af0a; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;Google Play Services&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;li2&quot; style=&quot;color: #e4af0a; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;span class=&quot;s2&quot; style=&quot;color: #454545; font-family: Menlo; font-size: 10px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&lt;a href=&quot;https://support.google.com/admob/answer/6128543?hl=en&quot;&gt;&lt;span class=&quot;s3&quot; style=&quot;color: #e4af0a; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;AdMob&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;li2&quot; style=&quot;color: #e4af0a; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;span class=&quot;s2&quot; style=&quot;color: #454545; font-family: Menlo; font-size: 10px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&lt;a href=&quot;https://firebase.google.com/policies/analytics&quot;&gt;&lt;span class=&quot;s3&quot; style=&quot;color: #e4af0a; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;Google Analytics for Firebase&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;b&gt;Log Data&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;I want to inform you that whenever you use my Service&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; in a case of an error in the app I collect data and information &lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;(&lt;/span&gt;through third party products&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;)&lt;/span&gt; on your phone called Log Data. This Log Data may include information such as your device Internet Protocol &lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;(“&lt;/span&gt;IP&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;”)&lt;/span&gt; address&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; device name&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; operating system version&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; the configuration of the app when utilizing my Service&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; the time and date of your use of the Service&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; and other statistics.&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;b&gt;Cookies&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;Cookies are files with a small amount of data that are commonly used as anonymous unique identifiers. These are sent to your browser from the websites that you visit and are stored on your device&#39;s internal memory.&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;This Service does not use these &lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;“&lt;/span&gt;cookies&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;”&lt;/span&gt; explicitly. However&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; the app may use third party code and libraries that use &lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;“&lt;/span&gt;cookies&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;”&lt;/span&gt; to collect information and improve their services. You have the option to either accept or refuse these cookies and know when a cookie is being sent to your device. If you choose to refuse our cookies&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; you may not be able to use some portions of this Service.&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;b&gt;Service Providers&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;I may employ third-party companies and individuals due to the following reasons:&lt;/p&gt;&lt;ul class=&quot;ul1&quot;&gt;&lt;li class=&quot;li1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;span class=&quot;s4&quot; style=&quot;font-family: Menlo; font-size: 10px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&lt;/span&gt;To facilitate our Service&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;li1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;span class=&quot;s4&quot; style=&quot;font-family: Menlo; font-size: 10px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&lt;/span&gt;To provide the Service on our behalf&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;li1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;span class=&quot;s4&quot; style=&quot;font-family: Menlo; font-size: 10px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&lt;/span&gt;To perform Service-related services&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;;&lt;/span&gt; or&lt;/li&gt;&lt;li class=&quot;li1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;span class=&quot;s4&quot; style=&quot;font-family: Menlo; font-size: 10px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&lt;/span&gt;To assist us in analyzing how our Service is used.&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;I want to inform users of this Service that these third parties have access to your Personal Information. The reason is to perform the tasks assigned to them on our behalf. However&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; they are obligated not to disclose or use the information for any other purpose.&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;b&gt;Security&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;I value your trust in providing us your Personal Information&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; thus we are striving to use commercially acceptable means of protecting it. But remember that no method of transmission over the internet&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; or method of electronic storage is 100% secure and reliable&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; and I cannot guarantee its absolute security.&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;b&gt;Links to Other Sites&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;This Service may contain links to other sites. If you click on a third-party link&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; you will be directed to that site. Note that these external sites are not operated by me. Therefore&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; I strongly advise you to review the Privacy Policy of these websites. I have no control over and assume no responsibility for the content&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; privacy policies&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; or practices of any third-party sites or services.&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;b&gt;Children&lt;/b&gt;&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;’&lt;/span&gt;&lt;b&gt;s Privacy&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;These Services do not address anyone under the age of 13. I do not knowingly collect personally identifiable information from children under 13 years of age. In the case I discover that a child under 13 has provided me with personal information&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; I immediately delete this from our servers. If you are a parent or guardian and you are aware that your child has provided us with personal information&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; please contact me so that I will be able to do necessary actions.&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;b&gt;Changes to This Privacy Policy&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;I may update our Privacy Policy from time to time. Thus&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; you are advised to review this page periodically for any changes. I will notify you of any changes by posting the new Privacy Policy on this page.&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;This policy is effective as of 2021-09-12&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;b&gt;Contact Us&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;If you have any questions or suggestions about my Privacy Policy&lt;span class=&quot;s1&quot; style=&quot;font-family: &amp;quot;.PingFang TC&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;,&lt;/span&gt; do not hesitate to contact me at thujmb@gmail.com.&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;color: #454545; font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/2970213057364565885/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2021/09/privacy-policy.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/2970213057364565885'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/2970213057364565885'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2021/09/privacy-policy.html' title='Privacy Policy'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-1514521550627297005</id><published>2020-07-08T18:18:00.003-07:00</published><updated>2022-09-08T20:26:33.004-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="APP"/><title type='text'>android X 是什麼</title><content type='html'>AndroidX 出現一陣子，隨著android版本的更新，看來 GOOGLE 未來是鐵了心要強迫大家用androidX了。到底android X是什麼。&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;android 開始的時期，是微軟稱霸的時期，所有作業系統都很難有一片天地。在APPLE手機出現之前，智慧手機還是一片安裝微軟系統的陽春機。我們說他陽春是因為軟體的開發者並沒有想象或是去感受一個可攜裝置的未來與使用方式。所以做出來的手機難用至極。這也導致了APPLE IPHONE一出現就席卷了整個世界。我還記得朋友拿iphone3在我面前擺弄的樣子，就像一個小孩發現了好玩的玩具一樣。&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;此時的google看到了手機市場，也推出了以android為作業系統的手機，這個時期最悲悽的就是NOKIA了。沒有跟上這個潮流，一下子就從天上跌到了海溝裡。在重力加速度的加持下，速度之快，直接深埋在海溝之中。&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;此時的android也沒有想過，智慧手機的進展會如何。還一堆人在討論，五吋手機太大了，未來一定還會縮小。也一堆人在討論，手機只會越來越大。今天看來，沒有想象力的人們，能討論的只是當下的問題。今天還有人在討論手機未來大小如何嗎？現在討論的是要如何人性化，更好用，更省電，更好一手掌控。&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;自然在android 3 的時候，為了平版，android加入了fragment功能，讓介面的排列可以更多樣，但是，新的功能如何跟舊的系統相容呢？這就是support library出現的原因了。從這裡每次寫程式都要考慮是要用 android.support.V4.app還是 android.support.V7.appcompat。&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;物換星移，漸漸的 android1, android2漸漸的看不到市佔了，但舊有的support V4 V7庫裡面還是有往下相容的物件與命名空間。所以也是到了要好好大掃除一下了。因此google 就推出了android X，把所有的物件跟命名空間都重整一下，這樣以後也不用再用V4、V7 這些命名。&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;主要改變&lt;/div&gt;&lt;div&gt;一 、原本android.support.*，都改成 androidx.*&lt;/div&gt;&lt;div&gt;二、appcompat-v7庫之類都改成appcompat即可，不用帶版號。&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;如何做出改變&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;一、目前新版android studio 3.4.2 ，打從新建一個計畫，就直接勾選了使用androidX。所以不用煩腦這個問題。&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;二、舊程式可以從refactor -&amp;gt; Migrate to AndroidX&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXeIgSbYstWZNV5ZnVc90ZDy8GLTXUgKza-PTvK3kWVq4u8g39ni5rxBF8ZD2UrOurz5iiO6eMGmclLR0ku_bm-xEcSehzW0in13_THTCE9RqgSu-J96EB76hyvI15uAWebJ6qhw1Lqe5g/s865/x.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;865&quot; data-original-width=&quot;684&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXeIgSbYstWZNV5ZnVc90ZDy8GLTXUgKza-PTvK3kWVq4u8g39ni5rxBF8ZD2UrOurz5iiO6eMGmclLR0ku_bm-xEcSehzW0in13_THTCE9RqgSu-J96EB76hyvI15uAWebJ6qhw1Lqe5g/s320/x.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;好心的備份&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;211&quot; data-original-width=&quot;503&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1_nbRWh1G5SITdq20ahPE_1OIYu8AuAlKPiYHpOWyZsZecnqyvnFoso5XFSzvEv6S5a4MT-IwxpxiZd8DmN4g7-jFN8jyLUgMQhQYowDaSJmYOjKl5mO16vd68ZjHHW18A9rxdL_LDZbJ/s320/x1.jpg&quot; style=&quot;text-align: left;&quot; width=&quot;320&quot; /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;選擇備份位置&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwz2wtURU5Jjsueauk6k0GknhxlZxwMN1x8E2_heBuEkbyJ0h229g7Kj3flwNzGVUFh8uyR6qN7jaUumW8XMwmZ7FENsJskt4FZf3vtuzeyO4yh3x-gV9AQWzmLY2lDnWq8FBvQnG8wEPT/s541/x2.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;541&quot; data-original-width=&quot;423&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwz2wtURU5Jjsueauk6k0GknhxlZxwMN1x8E2_heBuEkbyJ0h229g7Kj3flwNzGVUFh8uyR6qN7jaUumW8XMwmZ7FENsJskt4FZf3vtuzeyO4yh3x-gV9AQWzmLY2lDnWq8FBvQnG8wEPT/s320/x2.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;可能出現問題&lt;/div&gt;&lt;div&gt;一、要&amp;nbsp;&lt;span face=&quot;細明體&quot; style=&quot;background-color: white;&quot;&gt;Sdk Version 要28以上，這在Gradle 中修改&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;細明體&quot; style=&quot;background-color: white;&quot;&gt;compileSdkVersion 28&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;細明體&quot; style=&quot;background-color: white;&quot;&gt;二、多數會出現在xml的layout上。&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;font face=&quot;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;大體上不會有太大的陣痛，各位就放心轉下去吧！該來的就是要來的。就算做到一半想放棄也可以把備份復原即可。&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/1514521550627297005/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2020/07/android-x.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/1514521550627297005'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/1514521550627297005'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2020/07/android-x.html' title='android X 是什麼'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXeIgSbYstWZNV5ZnVc90ZDy8GLTXUgKza-PTvK3kWVq4u8g39ni5rxBF8ZD2UrOurz5iiO6eMGmclLR0ku_bm-xEcSehzW0in13_THTCE9RqgSu-J96EB76hyvI15uAWebJ6qhw1Lqe5g/s72-c/x.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-1714888131174522310</id><published>2020-07-08T17:28:00.000-07:00</published><updated>2020-07-08T17:28:55.091-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="APP"/><title type='text'>android 版本控制</title><content type='html'>隨著android來到 10 版。天啊！不知不覺。已過了那麼多年。為了顧及過去舊版本的朋友。我們在程式中就要因為版本而產生不同的程式碼。&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;以下是&lt;/div&gt;&lt;div&gt;&lt;pre style=&quot;background-color: white; font-family: 細明體;&quot;&gt;&lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;if &lt;/span&gt;(Build.VERSION.&lt;span style=&quot;color: #660e7a; font-style: italic; font-weight: bold;&quot;&gt;SDK_INT &lt;/span&gt;&amp;gt;= Build.VERSION_CODES.&lt;span style=&quot;color: #660e7a; font-style: italic; font-weight: bold;&quot;&gt;M&lt;/span&gt;) {&lt;br /&gt;     //大於等於 M 版本要做的事&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;} &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;else if &lt;/span&gt;(Build.VERSION.&lt;span style=&quot;color: #660e7a; font-style: italic; font-weight: bold;&quot;&gt;SDK_INT &lt;/span&gt;&amp;gt;= Build.VERSION_CODES.&lt;span style=&quot;color: #660e7a; font-style: italic; font-weight: bold;&quot;&gt;KITKAT&lt;/span&gt;) {&lt;br /&gt;   //大於等於 KITKAT 要做的事&lt;/pre&gt;&lt;pre style=&quot;background-color: white; font-family: 細明體;&quot;&gt;} &lt;span style=&quot;color: navy; font-weight: bold;&quot;&gt;else &lt;/span&gt;{&lt;br /&gt;    // 其它版本&lt;br /&gt;}&lt;/pre&gt;&lt;pre style=&quot;background-color: white; font-family: 細明體;&quot;&gt;在一些特別的功能上，不時會用到。先留下紀錄以備不時之需。&lt;/pre&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/1714888131174522310/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2020/07/android.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/1714888131174522310'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/1714888131174522310'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2020/07/android.html' title='android 版本控制'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-1887270300149648659</id><published>2019-11-30T03:26:00.001-08:00</published><updated>2019-11-30T03:26:41.273-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>python unicode 問題 decode encode</title><content type='html'>這個問題，是很多人的困擾。我們知道所有的文字在電腦中都有編碥。當我們按下鍵盤的 a 這個字母時，電腦作業系統本身並不是收到一個 a 字母，而是一個號碼 97，再從97 查出是a這個字母。這就是編碼。為什麼需要這樣做，因為文字就是一個圖。如果由鍵盤送出的訊號&lt;br /&gt;
是以圖為單位來傳送，那傳輸的硬體就要多設計頻寬。鍵盤本身也要存放這些文字的圖。要這樣設計硬體也不是不可以，但這個設計就不是很聰明。&lt;br /&gt;
&lt;br /&gt;
早期電腦的編碼是為了對應鍵盤上的鍵，產生了 ascii 碼。一個由8bit編碼的對應系統。可想而知。8bit也就只能對應256個文字。那全世界其它語言怎麼辨呢？當然就開始出現其它編碼。下面是一些常見的碼&lt;br /&gt;
&lt;br /&gt;
gbk 這個編碼包含了 繁簡中文，日文&lt;br /&gt;
&lt;br /&gt;
windows 中的&lt;br /&gt;
cp950 繁中&lt;br /&gt;
cp932 日文&lt;br /&gt;
cp1250 中歐語言&lt;br /&gt;
&lt;br /&gt;
cjk 中日韓&lt;br /&gt;
&lt;br /&gt;
big5 繁中&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: arial, 宋体, sans-serif; font-size: 14px; text-indent: 28px;&quot;&gt;Shift_JIS 日文&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
當一個系統慢慢的出現在各個國家的時候，上面這些編碼就各自出現了。&lt;br /&gt;
&lt;br /&gt;
隨著編碼越來越多，人們就會問，有那麼多編碼，為什麼不建一個完整的，把所有編碼都包進來的統一編碼呢？是的，unicode就是這樣的產物。&lt;br /&gt;
&lt;br /&gt;
進入我們今天的主題。&lt;br /&gt;
unicode 國際組織制定的，包括全世界所有語言文字與符號。 針對unicode又產生utf8，utf16，utf32的編碼。&lt;span style=&quot;color: red;&quot;&gt;這裡很重要。utf8，utf16，utf32是針對unicode&lt;/span&gt;，如果拿gbk要改為utf8那是行不通的。必需要gbk先轉成unicode，再由unicode轉為utf8或是utf16，或是utf32。&lt;br /&gt;
&lt;br /&gt;
所以為什麼我們在寫python開頭要加這一行&lt;br /&gt;
# -*- coding: utf-8 -*-&lt;br /&gt;
&lt;br /&gt;
就是讓python知道，他接下來要處理的程式中有 unicode 的非英語系文字。編碼要用utf8。&lt;br /&gt;
為什麼我們還是常常在python(2.7)遇到中文問題，尤其是換作業系統的時候？&lt;br /&gt;
&lt;br /&gt;
我們先試一下&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;a=&quot;我是人&quot;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;len(a)&lt;br /&gt;
9&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;type(a)&lt;br /&gt;
&amp;lt;type &#39;str&#39;&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;a=&lt;span style=&quot;color: red;&quot;&gt;u&lt;/span&gt;&quot;我是人&quot;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;len(a)&lt;br /&gt;
3&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;type(a)&lt;br /&gt;
&amp;lt;type &#39;unicode&#39;&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;b=a.encode(&#39;utf8&#39;)&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;type(b)&lt;br /&gt;
&amp;lt;type &#39;str&#39;&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;len(b)&lt;br /&gt;
9&lt;br /&gt;
&lt;br /&gt;
上面的過程，我們會發現python對字串的處理是用str這個型態。而str這個型態是以byte為單位。所以當我們第一個len(a)時會出現9，因為是 9 個byte。而不是以文字為單位，&quot;我是人&quot;是三個字。&lt;br /&gt;
&lt;br /&gt;
接下來我們用到 u 這個指示字，代表&quot;我是人&quot;是用unicode為編碼，所以len(a)就是3。unicode是以文字為單位。我們再把a用utf8編碼。對python來說，就變為str型態，所以len(b)又變為9 (9個byte)。如果我們要比對字串，只有相同編碼比對才有意義。&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;這裡我們用到encode這個指令。python中，encode(編碼)是從unicode 編成其它碼。而decode (解碼)是從其它碼&quot;解編碼&quot;為unicode。也就是說所有str型態只能用decode。&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
我們換平台時為什麼會常常遇到問題，通常是python程式需要讀作業系統的檔案。往往我們在mac上沒問題的比對字串，放到windows系統上就會出問題。因為python讀進來的字串都是str型態。我們必需知道在windows中的文字編碼是什麼，將其decode為unicode。個人最常遇到的就是windows中讀檔名，都是cp950編碼。每個讀進來的名字都要xxxx.decode(&#39;cp950&#39;).encode(&#39;utf8&#39;) 。指定錯了編碼是轉不回unicode的。最怕的是文字檔，連編碼都不知道怎麼辨！&lt;br /&gt;
&lt;br /&gt;
目前比較多人用chardet&lt;br /&gt;
pip install chardet&lt;br /&gt;
&lt;br /&gt;
用法&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;import chardet&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;a = &quot;我是人&quot;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;chardet.detect(a)&lt;br /&gt;
{&#39;confidence&#39;: 0.8765, &#39;language&#39;: &#39;&#39;, &#39;encoding&#39;: &#39;utf-8&#39;}&lt;br /&gt;
&lt;br /&gt;
用這個chartdet查看之後。就可以知道是什麼編碼。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/1887270300149648659/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2019/11/python-unicode-decode-encode.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/1887270300149648659'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/1887270300149648659'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2019/11/python-unicode-decode-encode.html' title='python unicode 問題 decode encode'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-6164478518262739523</id><published>2019-06-26T02:19:00.000-07:00</published><updated>2019-06-26T02:34:46.459-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="EXCEL VBA"/><title type='text'>VBA EXCEL 工作表變化 馬上執行 的作法  Worksheet_Change</title><content type='html'>沒想到還會用到 Excel 中的 VBA，當初寫VBA就是一段窮極無聊的日子，用Excel寫星象表…&lt;br /&gt;
現在居然要幫一位老大哥寫這樣的程式…當真所有的事，當下是很難知道它發生的意義是什麼…&lt;br /&gt;
&lt;br /&gt;
癈話不多說&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;先開啟EXCEL，存成副檔名為xlsm，這樣可以使用巨集功能。&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigDO4xmH1wotiSDKGCmRGQmRWDu9g6Eyjkhmo7-cl31f_-m088eoylhNbvMvxmTVOrcwcVbZRtH7W6OJ-TnSfcYETqLK1e6ninHA1EcglA4B9Q31SXSeFbXahE3HDdahbK2UcRmEbKwMar/s1600/ex1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;556&quot; data-original-width=&quot;363&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigDO4xmH1wotiSDKGCmRGQmRWDu9g6Eyjkhmo7-cl31f_-m088eoylhNbvMvxmTVOrcwcVbZRtH7W6OJ-TnSfcYETqLK1e6ninHA1EcglA4B9Q31SXSeFbXahE3HDdahbK2UcRmEbKwMar/s1600/ex1.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;然後看一上面，標籤列，有無開發人員選項。&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5CoJyxX24hZgoMAOwWFbFKwGt0LODucBhIhHwWF4TKjmrer8nc7F5uv2gO2bIZ8e4CaadIiKoT_xxlM5RJWQc6u6VqX9c3KmAOGUt6PbgbhACM6M-0V54H5ZJEXtndvcHrR4m7ObDAvYr/s1600/e2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;290&quot; data-original-width=&quot;508&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5CoJyxX24hZgoMAOwWFbFKwGt0LODucBhIhHwWF4TKjmrer8nc7F5uv2gO2bIZ8e4CaadIiKoT_xxlM5RJWQc6u6VqX9c3KmAOGUt6PbgbhACM6M-0V54H5ZJEXtndvcHrR4m7ObDAvYr/s1600/e2.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;如果沒有，從&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;檔案-&amp;gt;選項-&amp;gt;自定功能區-&amp;gt;開發人員(打勾)&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzXN3HOFKdBMEL3l82Zc9MaMtRzhaduOolfRXZUrEXUimGKOafPPlm4P-ks87biqa75W7Lbe8iSgctsXCeuu3PQVUSYG5PXW9CCO4jV7T5ThFyIuT56egP8vh0gpiWuirifpFdqCMbJN4n/s1600/e8.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;632&quot; data-original-width=&quot;832&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzXN3HOFKdBMEL3l82Zc9MaMtRzhaduOolfRXZUrEXUimGKOafPPlm4P-ks87biqa75W7Lbe8iSgctsXCeuu3PQVUSYG5PXW9CCO4jV7T5ThFyIuT56egP8vh0gpiWuirifpFdqCMbJN4n/s1600/e8.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;如果有，點擊 visual basic，就可以開始寫VBA&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirqdPCA-5ggC3DQgPlVzG1ma4koc33RODHxAkWlI1TCSdK3PcHg8QRW-brmm7482eBsrBDSQa80WT5pnxc2fm2uqsuqVEXA7VwgNYmXLCoVbTjMfHw1rsPIkhqz7nsNqglbrlnertNEdeY/s1600/e9.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;327&quot; data-original-width=&quot;625&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirqdPCA-5ggC3DQgPlVzG1ma4koc33RODHxAkWlI1TCSdK3PcHg8QRW-brmm7482eBsrBDSQa80WT5pnxc2fm2uqsuqVEXA7VwgNYmXLCoVbTjMfHw1rsPIkhqz7nsNqglbrlnertNEdeY/s1600/e9.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;我們的目的是這樣的，如果 worksheet中有任何的更動，都會執行一段程式。&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;所以我們先點擊左邊的工作表1，然後右邊的程式編輯欄中上面的選擇列中，選worksheet。要記得這個設定是&lt;span style=&quot;color: red;&quot;&gt;對應到個別的worksheet&lt;/span&gt;，所以如果有其它工作表，要個別寫對應的程式。如下&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgV-RugaZlcEfNFAwOB4MBahsRxIY89ic75gF0wF0ZkbeKBoff4n410wxLm-rmEp-O3T9_ziITEagmfZ4nMr-DIB9wir8diysp4JOs7ooZ8JSXZmVdpOa-WMHCEzX2rLqphShyphenhyphen3_kRekOJY/s1600/e3.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;786&quot; data-original-width=&quot;797&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgV-RugaZlcEfNFAwOB4MBahsRxIY89ic75gF0wF0ZkbeKBoff4n410wxLm-rmEp-O3T9_ziITEagmfZ4nMr-DIB9wir8diysp4JOs7ooZ8JSXZmVdpOa-WMHCEzX2rLqphShyphenhyphen3_kRekOJY/s1600/e3.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;接下來選右邊的change&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMeR5TefHPgFi0-1XnIY8id7h1cYI1sMQrRCWVdshyEfl_MC6vHv6zojh6OgZy3DlEUsYWFRRmRV_hkYrweGR9-hnTdQTwRmfyB_rW33w3RUJ-lIDT07q9u7sSC1TZKw2LecZEEHjaUgaW/s1600/e4.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;783&quot; data-original-width=&quot;934&quot; height=&quot;534&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMeR5TefHPgFi0-1XnIY8id7h1cYI1sMQrRCWVdshyEfl_MC6vHv6zojh6OgZy3DlEUsYWFRRmRV_hkYrweGR9-hnTdQTwRmfyB_rW33w3RUJ-lIDT07q9u7sSC1TZKw2LecZEEHjaUgaW/s640/e4.gif&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;選完就會自動產生兩個程式名。&amp;nbsp;Worksheet_Change與&amp;nbsp;Worksheet_SelectionChange，如下。Worksheet_Change是指任何在worksheet 上的變動，就會執行這個程式。Worksheet_SelectionChange是指，選定EXCEL中的格有變化，如本來選A1改點擊了B1，這個動作就會觸發Worksheet_SelectionChange。&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;我們在兩個程式中寫一個MsgBox, 如下&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;各位可以試試效果如何。只要點擊左上方，excel的小圖，就會回到excel的worksheet中。&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjP0Zdx4WtTZ6MEQ7dpuitGz7rOO-bzCP8J_4WrVXplZkIEMkmc358a6U2XsNo12R1K7NnOQJa-NFLz3TpYt0ErGhg8fj1KrGQe-QlRheSHzSZfiB-FGNymoS1AAZmDTeiTF2MBBnGuuQpn/s1600/e5.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;565&quot; data-original-width=&quot;816&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjP0Zdx4WtTZ6MEQ7dpuitGz7rOO-bzCP8J_4WrVXplZkIEMkmc358a6U2XsNo12R1K7NnOQJa-NFLz3TpYt0ErGhg8fj1KrGQe-QlRheSHzSZfiB-FGNymoS1AAZmDTeiTF2MBBnGuuQpn/s1600/e5.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;我們在&lt;span style=&quot;text-align: center;&quot;&gt;Worksheet_Change中增加三行程式，會在A1, A2, A3格中填入a, b, c。&lt;span style=&quot;color: red;&quot;&gt;各位是否有推論，這樣的寫法，會產生無窮迴圈？&lt;/span&gt;這個很重要！在寫&lt;/span&gt;&lt;span style=&quot;text-align: center;&quot;&gt;Worksheet_Change程式時，要很小心，如果是 工作表1自己的&lt;/span&gt;&lt;span style=&quot;text-align: center;&quot;&gt;Worksheet_Change要對工作表1自己做改變，就會進入無窮迴圈。&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;text-align: center;&quot;&gt;所以我們要能自由的開關觸發功能。用&amp;nbsp;&lt;/span&gt;&amp;nbsp;Application.EnableEvents&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGORwKrcXjW4pf8VXzKSzYcsf4yyvekeAgkTSfp4uYmoc5o3j5gi6FyKej77o2UfTwRSVvcmlQ9VxnFNo5QONfTNeo70F08ONXeIqz79eXphU5xRSAb8SaGI4226y3IlOb-fn58QfgiksM/s1600/e6.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;333&quot; data-original-width=&quot;497&quot; height=&quot;428&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGORwKrcXjW4pf8VXzKSzYcsf4yyvekeAgkTSfp4uYmoc5o3j5gi6FyKej77o2UfTwRSVvcmlQ9VxnFNo5QONfTNeo70F08ONXeIqz79eXphU5xRSAb8SaGI4226y3IlOb-fn58QfgiksM/s640/e6.gif&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;我們加入&amp;nbsp;&amp;nbsp;Application.EnableEvents ，再試試看。&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjek3dECzjtuHuzGKPJGZDyBNbTEjJdQ0ixc_W1lSH8P0WJKC1nIr7yV12yFKdYhQZsJ-5ubGiQ1mOlh0_iv1fTcnlm_fDG21hFo8DovoapRaW7vZcIc-HoHOkGnO-76EcC12Vx0ygugrKn/s1600/ee1.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;605&quot; data-original-width=&quot;811&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjek3dECzjtuHuzGKPJGZDyBNbTEjJdQ0ixc_W1lSH8P0WJKC1nIr7yV12yFKdYhQZsJ-5ubGiQ1mOlh0_iv1fTcnlm_fDG21hFo8DovoapRaW7vZcIc-HoHOkGnO-76EcC12Vx0ygugrKn/s1600/ee1.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;&amp;nbsp;如此這般。&lt;/b&gt;</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/6164478518262739523/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2019/06/vba-excel-worksheetchange.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/6164478518262739523'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/6164478518262739523'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2019/06/vba-excel-worksheetchange.html' title='VBA EXCEL 工作表變化 馬上執行 的作法  Worksheet_Change'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigDO4xmH1wotiSDKGCmRGQmRWDu9g6Eyjkhmo7-cl31f_-m088eoylhNbvMvxmTVOrcwcVbZRtH7W6OJ-TnSfcYETqLK1e6ninHA1EcglA4B9Q31SXSeFbXahE3HDdahbK2UcRmEbKwMar/s72-c/ex1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-5249344599402141630</id><published>2019-06-02T20:36:00.000-07:00</published><updated>2019-06-12T00:11:26.227-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Minst 手寫訓練集 python</title><content type='html'>以往我們有一個新的類神經訓練模型，我們都會用single pole或是double pole來測試模型的訓練結果。以目前類神經網路發展的狀況，single pole 與double pole已不能滿足需求。進一步，我們會使用MNIST訓練集來訓練。網址在此&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://yann.lecun.com/exdb/mnist/&quot;&gt;http://yann.lecun.com/exdb/mnist/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
一進去我們就看到三個作者 Yann LeCun, Corinna Cortes, Christopher J.C. Burges，我們向他們致敬。&lt;br /&gt;
&lt;br /&gt;
然後就是四個重要的檔案。&lt;br /&gt;
&lt;br /&gt;
&lt;tt&gt;&lt;a href=&quot;http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz&quot;&gt;train-images-idx3-ubyte.gz&lt;/a&gt;:&amp;nbsp;
training set images (9912422 bytes)&lt;/tt&gt;
&lt;br /&gt;
&lt;tt&gt;&lt;a href=&quot;http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz&quot;&gt;train-labels-idx1-ubyte.gz&lt;/a&gt;:&amp;nbsp;
training set labels (28881 bytes)&lt;/tt&gt;
&lt;br /&gt;
&lt;tt&gt;&lt;a href=&quot;http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz&quot;&gt;t10k-images-idx3-ubyte.gz&lt;/a&gt;:&amp;nbsp;&amp;nbsp;
test set images (1648877 bytes)&lt;/tt&gt;
&lt;br /&gt;
&lt;tt&gt;&lt;a href=&quot;http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz&quot;&gt;t10k-labels-idx1-ubyte.gz&lt;/a&gt;:&amp;nbsp;&amp;nbsp;
test set labels (4542 bytes)&lt;/tt&gt;
&lt;br /&gt;
&lt;br /&gt;
第一跟第二個是拿來訓練用的，第三跟第四個是拿來測試的。我們可以注意到有image跟labels兩種檔。image是圖檔，labels是對應圖檔的答案。&lt;br /&gt;
&lt;br /&gt;
雖然TensorFlow有方便的讀取方法。但如果我們想要自己用python讀來用。要如何做呢？&lt;br /&gt;
我們要先看一下網頁中的這部份 &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-T64SVIi71P2BXE_yMconRX0IGG9stfQxhQYLohN_zbrtVN99TFnq2_XVMes0sEC7-kdahi-tXhdI2FvysCcY9ERZ0URqiJawSB1bxbfete1aharC6liRxY8XiG9WfG4v1aSATe2-1wWy/s1600/2019-06-02+15-26-56+%25E7%259A%2584%25E8%259E%25A2%25E5%25B9%2595%25E6%2593%25B7%25E5%259C%2596.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;503&quot; data-original-width=&quot;1235&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-T64SVIi71P2BXE_yMconRX0IGG9stfQxhQYLohN_zbrtVN99TFnq2_XVMes0sEC7-kdahi-tXhdI2FvysCcY9ERZ0URqiJawSB1bxbfete1aharC6liRxY8XiG9WfG4v1aSATe2-1wWy/s1600/2019-06-02+15-26-56+%25E7%259A%2584%25E8%259E%25A2%25E5%25B9%2595%25E6%2593%25B7%25E5%259C%2596.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
我們可以看到offset，代表讀的byte數。就是說我們開了檔之後。read進來，以label檔來說，data[0:4]會等於2049。data[4:8]等於60000。&lt;br /&gt;
&lt;br /&gt;
了解檔案的格式，我們就可以寫一個小程式來讀讀看。&lt;br /&gt;
因為offset是4個為一個單位，所以我們先寫一下轉byte為數字的程式&lt;br /&gt;
&lt;br /&gt;
def b2i(b):&lt;br /&gt;
&amp;nbsp; &amp;nbsp; return int(codecs.encode(b, &#39;hex&#39;), 16)&lt;br /&gt;
&lt;br /&gt;
with open(&quot;.&quot;+os.sep+&quot;train-images.idx3-ubyte&quot;, &#39;rb&#39;) as f:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; data = f.read()&lt;br /&gt;
&amp;nbsp; &amp;nbsp; type = b2i(data[0:4]) &lt;span style=&quot;color: red;&quot;&gt;# image file 為 2051&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; dataLen = b2i(data[4:8]) &lt;span style=&quot;color: red;&quot;&gt;# 訓練集為 60000&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; rows = b2i(data[8:12])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; cols = b2i(data[12:16])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; getImage = np.frombuffer(data, dtype=np.uint8, offset=16)&lt;span style=&quot;color: red;&quot;&gt;#從offset 16 開始為圖資&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; getImage = getImage.reshape(dataLen, rows, cols)&lt;br /&gt;
&lt;br /&gt;
到這裡，圖資讀完，如果要把圖一張張存下來&lt;br /&gt;
&lt;br /&gt;
for i in range(0, len(getImage)):#小心，共有60000張圖！！&lt;br /&gt;
&amp;nbsp; &amp;nbsp; scipy.misc.imsave(str(i) + &quot;.jpg&quot;, getImage[i])&lt;br /&gt;
&lt;br /&gt;
讀label檔&lt;br /&gt;
&lt;br /&gt;
with open(&quot;.&quot;+os.sep+&quot;train-labels.idx1-ubyte&quot;, &#39;rb&#39;) as f:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; data = f.read()&lt;br /&gt;
&amp;nbsp; &amp;nbsp; type = b2i(data[0:4])&amp;nbsp;&lt;span style=&quot;color: red;&quot;&gt;# label file 為 2049&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; dataLen = b2i(data[4:8])&amp;nbsp;&lt;span style=&quot;color: red;&quot;&gt;# 訓練集為 60000&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; getLabel = np.frombuffer(data, dtype=np.uint8, offset=16)&lt;span style=&quot;color: red;&quot;&gt;#從offset 16 開始為label&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; getLabel = getLabel.reshape(dataLen)&lt;br /&gt;
&lt;br /&gt;
到這裡，圖資讀完，如果要把圖一張張存下來，加上答案為檔名&lt;br /&gt;
&lt;br /&gt;
for i in range(0, len(getImage)):&lt;span style=&quot;color: red;&quot;&gt;#小心，共有60000張圖！！&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; scipy.misc.imsave(str(i) + &quot;_&quot; + str(getLabel[i]) + &quot;.jpg&quot;, getImage[i])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
對！import 有&lt;br /&gt;
import os, codecs&lt;br /&gt;
import numpy as np&lt;br /&gt;
import scipy.misc&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/5249344599402141630/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2019/06/minst-python.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/5249344599402141630'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/5249344599402141630'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2019/06/minst-python.html' title='Minst 手寫訓練集 python'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-T64SVIi71P2BXE_yMconRX0IGG9stfQxhQYLohN_zbrtVN99TFnq2_XVMes0sEC7-kdahi-tXhdI2FvysCcY9ERZ0URqiJawSB1bxbfete1aharC6liRxY8XiG9WfG4v1aSATe2-1wWy/s72-c/2019-06-02+15-26-56+%25E7%259A%2584%25E8%259E%25A2%25E5%25B9%2595%25E6%2593%25B7%25E5%259C%2596.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-8578956035202836400</id><published>2019-05-23T23:22:00.001-07:00</published><updated>2019-05-26T19:25:42.958-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>python 變數 II</title><content type='html'>有時候我們在多個不同的class之間使用了同一個模組。而模組中有些變數，我們希望其可以跟著變動。&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
我們舉個例子來看看&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3&gt;
第一個檔案 vv.py&lt;/h3&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
import os, sys&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
class vv():&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;vva = 1&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;vvb = 2&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3&gt;
第二個檔案 v1.py&lt;/h3&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
import vv&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
class v1():&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;def __init__(self):&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;self.aa = vv.vv()&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.aa.vva=9999&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;def show(self):&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;print self.aa.vva&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;print self.aa.vvb&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3&gt;
第三個檔案為主程式 vmain.py&lt;/h3&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
import vv&lt;/div&gt;
&lt;div&gt;
import v1&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
class main():&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;def __init__(self):&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;self.a = v.vv()&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;def show(self):&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;print self.a.vva&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;print self.a.vvb&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;def change(self):&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;self.a.vva=12345&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;self.a.vvb=54321&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;def gotV1(self):&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;aa = v1.v1()&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;aa.show()&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
if __name__ == &#39;__main__&#39;:&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;aa=main()&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;aa.show()&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;aa.change()&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;aa.show()&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;aa.gotV1()&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;print &quot; new object &quot;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;bb = main()&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;bb.show()&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
當我們執行了vmain.py 得到&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
1&lt;/div&gt;
&lt;div&gt;
2&lt;/div&gt;
&lt;div&gt;
12345&lt;/div&gt;
&lt;div&gt;
54321&lt;/div&gt;
&lt;div&gt;
9999&lt;/div&gt;
&lt;div&gt;
2&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;new object&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
1&lt;/div&gt;
&lt;div&gt;
2&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
我們企圖在change中改變vva的數字，。這個合理，每一個新的物件，都該保有其參數原來的值。如果我們希望new object下，新物件的值也一起被改變呢？&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
import vv&lt;/div&gt;
&lt;div&gt;
import v1&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
class main():&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;def __init__(self):&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;self.a = v.vv()&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;def show(self):&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;print self.a.vva&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;print self.a.vvb&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;def change(self):&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;self.a.__class__.vva=8888888888888888&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;self.a.vvb=54321&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;#self.a.change()&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;def gotV1(self):&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;aa = v1.v1()&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;aa.show()&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
if __name__ == &#39;__main__&#39;:&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;aa=main()&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;aa.show()&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;aa.change()&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;aa.show()&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;aa.gotV1()&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;print &quot; new object &quot;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;bb = main()&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;bb.show()&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
當我們執行了vmain.py 得到&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
1&lt;/div&gt;
&lt;div&gt;
2&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: red;&quot;&gt;88888888&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
54321&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: red;&quot;&gt;9999&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
2&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;new object&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: red;&quot;&gt;88888888&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
2&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
使用__class__，就可以讓模組中的參數，全面的改變了。注意到9999，這個在v1.py中被設定的值並沒有被__class__改變。如同之前提到過，python中給定一個值這件事，會產生一個新變數。所以__class__改變不會改變到 v1.py中的vv 物件的vva。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/8578956035202836400/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2019/05/python-ii.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/8578956035202836400'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/8578956035202836400'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2019/05/python-ii.html' title='python 變數 II'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-1804581059998350324</id><published>2019-05-19T20:13:00.001-07:00</published><updated>2019-05-19T20:13:52.292-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>python aubio 安裝</title><content type='html'>在window 10，以pip 安裝 aubio時出現如下的錯誤。這是安裝環境的問題。&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; line-height: 1.45; margin-bottom: 16px; overflow-wrap: normal; overflow: auto; padding: 16px;&quot;&gt;&lt;code style=&quot;background: transparent; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;&quot;&gt;Running &quot;pkg-config --libs --cflags libavformat&quot; failed: WindowsError(2, &#39;The system cannot find the file specified&#39;)
Running &quot;pkg-config --libs --cflags libavutil&quot; failed: WindowsError(2, &#39;The system cannot find the file specified&#39;)
Running &quot;pkg-config --libs --cflags libavresample&quot; failed: WindowsError(2, &#39;The system cannot find the file specified&#39;)
Running &quot;pkg-config --libs --cflags jack&quot; failed: WindowsError(2, &#39;The system cannot find the file specified&#39;)
Running &quot;pkg-config --libs --cflags sndfile&quot; failed: WindowsError(2, &#39;The system cannot find the file specified&#39;)
Running &quot;pkg-config --libs --cflags samplerate&quot; failed: WindowsError(2, &#39;The system cannot&lt;/code&gt;&lt;/pre&gt;
我們要為 widnow 環境安裝上 visual C++, 如下說明&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://wiki.python.org/moin/WindowsCompilers&quot;&gt;https://wiki.python.org/moin/WindowsCompilers&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
在安裝前，我們先確定setup tool為新的&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #f3f5f7; border: 1pt solid rgb(174, 189, 204); font-family: courier, monospace; font-size: 14.1728px; overflow-wrap: break-word; padding: 5pt; white-space: pre-wrap;&quot;&gt;pip install --upgrade setuptools&lt;/pre&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
針對自己的python選Visual C++&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiN8xJXQ0UAhGoaDI7BCKly1Vg7nofWXHkYRPmcNES-t6gVKwTWQfvC2WH0Lujm-wZtrFo8VH-5EXjl4O4xZYeySz1ITTvAIqCpj_tGMQ8MvDkUB2AYueqrfNQz-fg4HxvpuIFJ265XNTLb/s1600/1558321736857.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;135&quot; data-original-width=&quot;264&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiN8xJXQ0UAhGoaDI7BCKly1Vg7nofWXHkYRPmcNES-t6gVKwTWQfvC2WH0Lujm-wZtrFo8VH-5EXjl4O4xZYeySz1ITTvAIqCpj_tGMQ8MvDkUB2AYueqrfNQz-fg4HxvpuIFJ265XNTLb/s1600/1558321736857.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
在連結中找到下載的網址。個人的python為2.7找到如下&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOox3_wSi9xwQA_9mrwvvcdswyAsHgYO6QNZBRq1tbtVLmn_hRxKbHHng2GwL8jmOGg0LnkEIK95uN6h8M85uHCprI_t44Pt0crcNS2ahAW5k4WddeDWCc_QORgLEZsR0clhWMfT3xmJPK/s1600/1558321930591.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;135&quot; data-original-width=&quot;722&quot; height=&quot;114&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOox3_wSi9xwQA_9mrwvvcdswyAsHgYO6QNZBRq1tbtVLmn_hRxKbHHng2GwL8jmOGg0LnkEIK95uN6h8M85uHCprI_t44Pt0crcNS2ahAW5k4WddeDWCc_QORgLEZsR0clhWMfT3xmJPK/s640/1558321930591.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
C++ Compiler for Python 2.7 下載完成，安裝。&lt;br /&gt;
然後再安裝一次aubio即完成。</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/1804581059998350324/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2019/05/python-aubio.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/1804581059998350324'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/1804581059998350324'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2019/05/python-aubio.html' title='python aubio 安裝'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiN8xJXQ0UAhGoaDI7BCKly1Vg7nofWXHkYRPmcNES-t6gVKwTWQfvC2WH0Lujm-wZtrFo8VH-5EXjl4O4xZYeySz1ITTvAIqCpj_tGMQ8MvDkUB2AYueqrfNQz-fg4HxvpuIFJ265XNTLb/s72-c/1558321736857.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-286054957633887330</id><published>2019-05-16T20:50:00.001-07:00</published><updated>2019-05-16T20:54:59.111-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Python global variable</title><content type='html'>def g():&lt;br /&gt;
&amp;nbsp; &amp;nbsp; var =1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; print var&lt;br /&gt;
&lt;br /&gt;
var = 10&lt;br /&gt;
&lt;br /&gt;
print var&lt;br /&gt;
g()&lt;br /&gt;
print var&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;答案為&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
10&lt;/div&gt;
&lt;div&gt;
1&lt;/div&gt;
&lt;div&gt;
10&lt;/div&gt;
&lt;div&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
這個很容易理解，本來g()裡面的參數就不會跟外面的混為一談。&lt;/div&gt;
&lt;div&gt;
def g():&lt;br /&gt;
&amp;nbsp; &amp;nbsp; print var&lt;br /&gt;
&lt;br /&gt;
var = 10&lt;br /&gt;
&lt;br /&gt;
print var&lt;br /&gt;
g()&lt;br /&gt;
print var&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;答案為&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
10&lt;/div&gt;
&lt;div&gt;
10&lt;/div&gt;
&lt;div&gt;
10&lt;/div&gt;
&lt;div&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
超有趣，g()中的var，居然直接找到外面的var。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
def g():&lt;br /&gt;
&amp;nbsp; &amp;nbsp; print var&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;global &lt;/span&gt;var&lt;br /&gt;
var = 10&lt;br /&gt;
&lt;br /&gt;
print var&lt;br /&gt;
g()&lt;br /&gt;
print var&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;答案為&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
10&lt;/div&gt;
&lt;div&gt;
10&lt;/div&gt;
&lt;div&gt;
10&lt;/div&gt;
&lt;div&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
多宣告global，跟上一種寫法一樣。好像內定就以為是global&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
def g():&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: red;&quot;&gt; var = 1&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; print var&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;global&lt;/span&gt; var&lt;br /&gt;
var = 10&lt;br /&gt;
&lt;br /&gt;
print var&lt;br /&gt;
g()&lt;br /&gt;
print var&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;答案為&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
10&lt;/div&gt;
&lt;div&gt;
1&lt;/div&gt;
&lt;div&gt;
10&lt;/div&gt;
&lt;div&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
g()中多了var = 1怎麼又認為不是外部的var了呢？外部var明明有宣告為 global了。這樣就可理解，上兩種寫法，因為沒有在 g()中給定 var 一個值。所以python 認為g()裡面的var與外面的是一樣的。所以給一個值，python會做出新變數。這樣我們可以推論，如果有沒新宣告為global不能給值。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;gt;&amp;gt;&amp;gt; global v = 1&lt;/div&gt;
&lt;div&gt;
SyntaxError: invalid syntax&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
沒錯，改成&lt;/div&gt;
&lt;div&gt;
global v #先宣告是global&lt;/div&gt;
&lt;div&gt;
v = 1&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
嗯…&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
def g():&lt;br /&gt;
&amp;nbsp; &amp;nbsp; global var&lt;br /&gt;
&amp;nbsp; &amp;nbsp; var =1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; print var&lt;br /&gt;
&lt;br /&gt;
var = 10&lt;br /&gt;
&lt;br /&gt;
print var&lt;br /&gt;
g()&lt;br /&gt;
print var&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;答案為&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
10&lt;/div&gt;
&lt;div&gt;
1&lt;/div&gt;
&lt;div&gt;
1&lt;/div&gt;
&lt;div&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
因為在 g() 中先宣造 var是一個外部共用(global)的參數，所以g()會去找var在哪裡被宣告過。&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/286054957633887330/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2019/05/python-global-variable.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/286054957633887330'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/286054957633887330'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2019/05/python-global-variable.html' title='Python global variable'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-6293873871931911770</id><published>2019-05-14T21:04:00.003-07:00</published><updated>2019-05-16T20:24:33.450-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>python  繼承</title><content type='html'>import ttk&lt;br /&gt;
import re&lt;br /&gt;
import os, sys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class Computer():&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;keyboard = &quot;bluetooth&quot;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;mouse = &quot;bluetooth&quot;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;def __init__(self, keyboard = &quot;wire&quot;, mouse = &quot;wire&quot;):&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;         &lt;/span&gt;self.keyboard = keyboard&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;         &lt;/span&gt;self.mouse = mouse&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;def getKeyboard(self):&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;        &lt;/span&gt;print &quot;keyboard is &quot; + self.keyboard&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;def getMouse(self):&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;        &lt;/span&gt;print &quot;mouse is &quot; + self.mouse&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;def changeKeyboard(self, keyboard):&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;self.keyboard = self.keyboard + &quot;-&quot; + keyboard&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;print self.keyboard&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
class Server(Computer):&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;interface = &quot;scsi&quot;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;harddisk = &quot;SD&quot;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;def __init__(self, keyboard=&quot;wire&quot;, mouse = &quot;wire&quot;, interface = &quot;ide&quot;, harddisk = &quot;drive&quot;):&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;        &lt;/span&gt;Computer.__init__(self, keyboard, mouse)&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;#這裡在python 3要改成 super().__init__(keyboard, mouse)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;        &lt;/span&gt;self.interface = interface&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;        &lt;/span&gt;self.harddisk = harddisk&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;def changeKeyboard(self, keyboard):&lt;span style=&quot;color: red;&quot;&gt;#與其認為是overwrite不如想作是一個&quot;新的&quot;屬於Server物件的新方法。&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;        &lt;/span&gt;self.keyboard = keyboard + &quot; 1&quot;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;        &lt;/span&gt;print self.keyboard&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;def getKeyboard(self):&lt;span style=&quot;color: red;&quot;&gt;#與其認為是overwrite不如想作是一個&quot;新的&quot;屬於Server物件的新方法。&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;        &lt;/span&gt;print &quot;keyboard is &quot; + self.keyboard +&quot; 2&quot;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
c1 = Computer(&quot;red&quot;, &quot;blue&quot;)&lt;br /&gt;
s1 = Server(&quot;yes&quot;, &quot;no&quot;, &quot;ddd&quot;, &quot;kkk&quot;)&lt;br /&gt;
&lt;br /&gt;
print &quot;### Computer ###&quot;&lt;br /&gt;
c1.getKeyboard()&lt;br /&gt;
c1.getMouse()&lt;br /&gt;
print &quot;### server ###&quot;&lt;br /&gt;
s1.getKeyboard()&lt;br /&gt;
s1.getMouse()&lt;span style=&quot;color: red;&quot;&gt;#S1用到從Computer繼承的getMouse()&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
print &quot;### change keyboard ###&quot;&lt;br /&gt;
c1.changeKeyboard(&quot;wire&quot;)&lt;br /&gt;
s1.changeKeyboard(&quot;no keyboard&quot;)&lt;br /&gt;
&lt;br /&gt;
print &quot;### Computer ###&quot;&lt;br /&gt;
c1.getKeyboard()&lt;br /&gt;
c1.getMouse()&lt;br /&gt;
print &quot;### server ###&quot;&lt;br /&gt;
s1.getKeyboard()&lt;br /&gt;
s1.getMouse()&lt;span style=&quot;color: red;&quot;&gt;#S1用到從Computer繼承的getMouse()&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
結果&lt;br /&gt;
### Computer ###&lt;br /&gt;
keyboard is red&lt;br /&gt;
mouse is blue&lt;br /&gt;
### server ###&lt;br /&gt;
keyboard is yes 2&lt;br /&gt;
mouse is no&lt;br /&gt;
### change keyboard ###&lt;br /&gt;
red-wire&lt;br /&gt;
no keyboard 1&lt;br /&gt;
### Computer ###&lt;br /&gt;
keyboard is red-wire&lt;br /&gt;
mouse is blue&lt;br /&gt;
### server ###&lt;br /&gt;
keyboard is no keyboard 1 2&lt;br /&gt;
mouse is no&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/6293873871931911770/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2019/05/python.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/6293873871931911770'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/6293873871931911770'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2019/05/python.html' title='python  繼承'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-241322552875075268</id><published>2019-05-13T02:01:00.001-07:00</published><updated>2019-05-13T02:01:13.314-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>tkinter check button</title><content type='html'>先宣個一個參數的物件&lt;br /&gt;
&lt;br /&gt;
varB = tk.BooleanVar()&lt;br /&gt;
&lt;br /&gt;
set&amp;nbsp; 初始值&lt;br /&gt;
&lt;br /&gt;
varB.set(True)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
給 check button 設定 var 參數&lt;br /&gt;
ckBtn = tk.Checkbutton(root, text=&quot;I am a check button&quot;,var=varB)&lt;br /&gt;
ckBtn.grid(row=0, column =&amp;nbsp; 0)&lt;br /&gt;
&lt;br /&gt;
想要得到參數&lt;br /&gt;
&lt;br /&gt;
ckBtn.get()&lt;br /&gt;
&lt;br /&gt;
如&lt;br /&gt;
&lt;br /&gt;
if&amp;nbsp; ckBtn.get() is True:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; print &quot;I am true&quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
也可以把參數換成String&lt;/div&gt;
&lt;br /&gt;
varB = tk.&lt;span style=&quot;color: inherit; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: inherit; white-space: pre-wrap;&quot;&gt;StringVar()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: inherit; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: inherit; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
給 check button 設定 var 參數&lt;br /&gt;
&lt;span style=&quot;color: inherit; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: inherit; white-space: pre-wrap;&quot;&gt;ckBtn = tk.Checkbutton(root, text=&quot;i am a check button&quot;, var=varB, &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: inherit; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: inherit; white-space: pre-wrap;&quot;&gt;                              onvalue=&quot;yes&quot;, offvalue=&quot;no&quot;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: inherit; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: inherit; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;span style=&quot;color: inherit; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: inherit; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
想要得到參數&lt;br /&gt;
&amp;nbsp;ckBtn.get()&lt;br /&gt;
&lt;br /&gt;
如&lt;br /&gt;
&lt;br /&gt;
if&amp;nbsp; ckBtn.get() == &quot;yes&quot;:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;I am yes&quot;</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/241322552875075268/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2019/05/tkinter-check-button.html#comment-form' title='1 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/241322552875075268'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/241322552875075268'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2019/05/tkinter-check-button.html' title='tkinter check button'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-5834114740498342379</id><published>2019-04-25T01:16:00.000-07:00</published><updated>2019-04-25T01:16:35.944-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>python 變數</title><content type='html'>幾個小測試&lt;br /&gt;
&lt;br /&gt;
class kk:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; i=5&lt;br /&gt;
&amp;nbsp; &amp;nbsp; def dd(self):&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i=3&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;kk.i&lt;br /&gt;
5&lt;br /&gt;
&amp;gt;&amp;gt;a=kk()&lt;br /&gt;
&amp;gt;&amp;gt;a.i&lt;br /&gt;
5&lt;br /&gt;
&amp;gt;&amp;gt;a.dd()&lt;br /&gt;
&amp;gt;&amp;gt;a.i&lt;br /&gt;
5&lt;br /&gt;
&amp;gt;&amp;gt;a.i=10&lt;br /&gt;
&amp;gt;&amp;gt;a.i&lt;br /&gt;
10&lt;br /&gt;
&amp;gt;&amp;gt; kk.i&lt;br /&gt;
5&lt;br /&gt;
&lt;br /&gt;
######################################################&lt;br /&gt;
&lt;br /&gt;
class kk:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; i=5&lt;br /&gt;
&amp;nbsp; &amp;nbsp; def dd(self):&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.__class__.i=3&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;kk.i&lt;br /&gt;
5&lt;br /&gt;
&amp;gt;&amp;gt;a=kk()&lt;br /&gt;
&amp;gt;&amp;gt;a.i&lt;br /&gt;
5&lt;br /&gt;
&amp;gt;&amp;gt;a.dd()&lt;br /&gt;
&amp;gt;&amp;gt;a.i&lt;br /&gt;
3&lt;br /&gt;
&amp;gt;&amp;gt;kk.i&lt;br /&gt;
3&lt;br /&gt;
#####################################################&lt;br /&gt;
&lt;br /&gt;
class kk:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; i=5&lt;br /&gt;
&amp;nbsp; &amp;nbsp; def dd(self):&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.i=3&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; kk.i&lt;br /&gt;
5&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; a=kk()&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; a.i&lt;br /&gt;
5&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; a.dd()&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; a.i&lt;br /&gt;
3&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; kk.i&lt;br /&gt;
5&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
這個例子可以理解到 self 有挷定參數至當下這個物件的功能&lt;br /&gt;
#####################################################&lt;br /&gt;
&lt;br /&gt;
class kk:&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;self.i=5&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;def dd(self):&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;i=4&lt;br /&gt;
&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
&amp;nbsp; File &quot;&amp;lt;pyshell#46&amp;gt;&quot;, line 1, in &amp;lt;module&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; class kk:&lt;br /&gt;
&amp;nbsp; File &quot;&amp;lt;pyshell#46&amp;gt;&quot;, line 2, in kk&lt;br /&gt;
&amp;nbsp; &amp;nbsp; self.i=5&lt;br /&gt;
NameError: name &#39;self&#39; is not defined&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
self 不能直接下在class 下用，要用__init__&lt;br /&gt;
&lt;br /&gt;
class kk:&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;def __init__(self):&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;self.i=5&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;def dd(self):&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;i=3&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; kk.i&lt;br /&gt;
&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
&amp;nbsp; File &quot;&amp;lt;pyshell#55&amp;gt;&quot;, line 1, in &amp;lt;module&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; kk.i&lt;br /&gt;
AttributeError: class kk has no attribute &#39;i&#39;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; a=kk()&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; a.i&lt;br /&gt;
5&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; a.dd()&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; a.i&lt;br /&gt;
5&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/5834114740498342379/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2019/04/python.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/5834114740498342379'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/5834114740498342379'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2019/04/python.html' title='python 變數'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-636222661690375903</id><published>2019-04-22T20:26:00.002-07:00</published><updated>2019-04-22T20:26:58.089-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>python 動態 import</title><content type='html'>在python有時候我們會用到需要動態的import模組&lt;br /&gt;
&lt;br /&gt;
方法如下&lt;br /&gt;
&lt;br /&gt;
sys1 = __import__(&#39;sys&#39;)&lt;br /&gt;
&lt;br /&gt;
其實上面這行就等於&lt;br /&gt;
&lt;br /&gt;
import sys as sys1&lt;br /&gt;
&lt;br /&gt;
既然可以這樣 import，我們可以多個模組一起&lt;br /&gt;
&lt;br /&gt;
ms = [ &#39;re&#39;, &#39;os&#39;, &#39;sys&#39;]&lt;br /&gt;
&lt;br /&gt;
ims =&amp;nbsp;&lt;span style=&quot;background-color: white; color: #222222;&quot;&gt;map(__import__, ms)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #222222;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #222222;&quot;&gt;我們來看一下 python 的版本&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
ims[2].version&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
如此這般。</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/636222661690375903/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2019/04/python-import.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/636222661690375903'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/636222661690375903'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2019/04/python-import.html' title='python 動態 import'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-4817092530040962030</id><published>2019-04-19T00:42:00.001-07:00</published><updated>2019-04-19T00:46:43.611-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="APP"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><title type='text'>得到 關於手機 的訊息</title><content type='html'>&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #7f0055; font-family: monospace; font-size: 12px; font-stretch: inherit; font-weight: bold; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #3f7f5f; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;android.os.Build&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;
&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;Build中可以取得手機中的一些資訊如下&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #3f7f5f; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;主機版名稱&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #ff8000; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;Build&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #006633; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;BOARD&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f9f9f9; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: #f9f9f9; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;硬體名稱 = Build.HARDWARE;
&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #3f7f5f; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;品牌名稱&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #110000;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #ff8000; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;Build&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #006633; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;BRAND&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;
&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #3f7f5f; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;CPU名稱&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #ff8000; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;Build&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #006633; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;CPU_ABI&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;
&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #3f7f5f; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;設備名稱&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #ff8000; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;Build&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #006633; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;DEVICE&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;
&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #3f7f5f; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;版本號碼&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #ff8000; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;Build&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #006633; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;DISPLAY&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;
&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #3f7f5f; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;設備識別碼&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #ff8000; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;Build&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #006633; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;FINGERPRINT&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;
&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #3f7f5f; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;HOST&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #110000;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #ff8000; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;Build&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #006633; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;HOST&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;
&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #3f7f5f; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;版本號碼&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #ff8000; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;Build&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #006633; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;ID&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;
&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #3f7f5f; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;製造商&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #ff8000; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;Build&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #006633; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;MANUFACTURER&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;
&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #3f7f5f; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;模組號碼&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #ff8000; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;Build&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #006633; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;MODEL&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;
&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #3f7f5f; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;產品名稱&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #ff8000; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;Build&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #006633; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;PRODUCT&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;
&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #3f7f5f; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;設備描述&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #ff8000; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;Build&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #006633; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;TAGS&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;
&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #3f7f5f; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;設備類別&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #ff8000; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;Build&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #006633; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;TYPE&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;
&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #3f7f5f; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;USER&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #ff8000; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;Build&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #110000; font-family: monospace; font-size: 12px; white-space: pre;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #006633; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;USER&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f9f9f9; border: 0px; color: #0000c0; font-family: monospace; font-size: 12px; font-stretch: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: #0000c0; font-family: monospace;&quot;&gt;&lt;span style=&quot;background-color: #f9f9f9; font-size: 13.3333px; white-space: pre;&quot;&gt;結果&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0000c0; font-family: monospace;&quot;&gt;&lt;span style=&quot;background-color: #f9f9f9; font-size: 13.3333px; white-space: pre;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYlZ52yXfIXAiwn5h_UnK6AJV2K-YYJ4wHkZJwwiCnICDPoNiumWuahpRYZqLZ-REYz12rnbjYJJNRkDW3szrrtZzgaMCr-pn4N2sArruFMbyUIsxV0xq6MwY5Iso_TadQBqfSrEFhfpni/s1600/1555659391352.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;351&quot; data-original-width=&quot;423&quot; height=&quot;265&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYlZ52yXfIXAiwn5h_UnK6AJV2K-YYJ4wHkZJwwiCnICDPoNiumWuahpRYZqLZ-REYz12rnbjYJJNRkDW3szrrtZzgaMCr-pn4N2sArruFMbyUIsxV0xq6MwY5Iso_TadQBqfSrEFhfpni/s320/1555659391352.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/4817092530040962030/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2019/04/blog-post.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/4817092530040962030'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/4817092530040962030'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2019/04/blog-post.html' title='得到 關於手機 的訊息'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYlZ52yXfIXAiwn5h_UnK6AJV2K-YYJ4wHkZJwwiCnICDPoNiumWuahpRYZqLZ-REYz12rnbjYJJNRkDW3szrrtZzgaMCr-pn4N2sArruFMbyUIsxV0xq6MwY5Iso_TadQBqfSrEFhfpni/s72-c/1555659391352.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-8863788051610230123</id><published>2019-04-11T20:07:00.002-07:00</published><updated>2019-04-11T20:17:39.569-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Python Tkinter 快速上手</title><content type='html'>&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
想像一個介面如下&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKeFRoSA6goqJ6JDRD8QXx8og_rU0R0KhtouVmrS9dUKoJdHr0Lkkx4-QBx4zggJcCFesw7InbobO9uZeyUhjOjOMU4EB0uwmlrOiF2PJ4-Of2dnIjj9CL0aD-ZtFaCIRKsP8FiIGQ_aiL/s1600/tkinter.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;659&quot; data-original-width=&quot;687&quot; height=&quot;305&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKeFRoSA6goqJ6JDRD8QXx8og_rU0R0KhtouVmrS9dUKoJdHr0Lkkx4-QBx4zggJcCFesw7InbobO9uZeyUhjOjOMU4EB0uwmlrOiF2PJ4-Of2dnIjj9CL0aD-ZtFaCIRKsP8FiIGQ_aiL/s320/tkinter.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;python 2.7 的範例如下&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;注意：&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h4 style=&quot;background-color: white; box-sizing: border-box; color: #2f2f2f; font-size: 20px; line-height: 1.7; margin: 0px 0px 15px;&quot;&gt;
同一個視窗中如果使用grid()就不可使用 pack()，兩者選其一用即可D&lt;/h4&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;import Tkinter as tk&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;import tkMessageBox&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;import ttk&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;class TKDemo():&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;def __init__(self, master=None):&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;self.rowCount=0#用這個row count，以免以後修改LAYOUT, 中間要插入新的列，新列之後的row都要改&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;self.root = master&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;self.createWidgets()&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;def createWidgets(self):&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;label1=tk.Label(self.root, text=&quot;First&quot;)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;label2=tk.Label(self.root, text=&quot;Second&quot; )&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;label1row = self.rowCount&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;label1.grid(row=label1row, sticky=tk.W)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;self.rowCount += 1&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;label2row = self.rowCount&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;label2.grid(row=label2row, sticky=tk.W)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;self.rowCount += 1&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;e1 = tk.Entry(self.root)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;e2 = tk.Entry(self.root)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;photo=tk.PhotoImage(file=&#39;ibtn.gif&#39;)#png, jpeg, 都不能用。&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;b=tk.Button(self.root, image=photo, text=&quot;ppp&quot;, relief=tk.RIDGE)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;b.grid(row=label1row, column=2)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;#b.config(image=photo)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;e1.grid(row=label1row, column=1, sticky=&quot;we&quot;)#靠東靠西延伸&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;e2.grid(row=label2row, column=1, columnspan=2,&amp;nbsp; sticky=&quot;we&quot;)#長度為兩欄，靠東靠西延伸&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;seprow = self.rowCount&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ttk.Separator(self.root,orient=tk.HORIZONTAL).grid(row=seprow, columnspan=3, sticky=&quot;we&quot;, pady=10)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;self.rowCount += 1&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;var=tk.StringVar()&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;r1=tk.Radiobutton(self.root,text=&#39;Option A&#39;,variable=var,value=&#39;A&#39;)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;r2=tk.Radiobutton(self.root,text=&#39;Option B&#39;,variable=var,value=&#39;B&#39;)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;r3=tk.Radiobutton(self.root,text=&#39;Option C&#39;,variable=var,value=&#39;C&#39;)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;r1row = self.rowCount&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;r1.grid(row=r1row, column=1, sticky=tk.W)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;self.rowCount += 1&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;r2row = self.rowCount&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;r2.grid(row=r2row, column=1, sticky=tk.W)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;self.rowCount += 1&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;r3row = self.rowCount&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;r3.grid(row=r3row, column=1, sticky=tk.W)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;self.rowCount += 1&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;imageLabel = tk.Label(self.root, image = photo, relief=tk. SUNKEN)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;imageLabel.image = photo #沒出現圖要加這行&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;imageLabel.grid(row=r2row, column=2)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;canvas = tk.Canvas(self.root, width =400, height=400, relief=tk.SUNKEN)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;xy = 10, 105, 100, 200&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;canvas.create_arc(xy, start=0, extent=270, fill=&#39;gray60&#39;)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;canvas.create_polygon(0,0,0,400,400,400,400,0, fill=&#39;red&#39;)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;canvas.create_arc(xy, start=270, extent=5, fill=&#39;gray70&#39;)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;canvas.create_arc(xy, start=275, extent=35, fill=&#39;gray80&#39;)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;canvas.create_arc(xy, start=310, extent=49, fill=&#39;gray90&#39;)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;canvas.create_polygon(100,100,285,125,166,177,210,199,205,105, fill=&#39;white&#39;)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;canvas.create_image(145, 280, image=photo, anchor=tk.CENTER)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;canvasrow = self.rowCount&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;canvas.grid(row=canvasrow, column=1)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;self.rowCount += 1&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;scale = tk.Scale(self.root, orient=tk.VERTICAL, length=400, from_=0, to=400,tickinterval=50, relief=tk.SUNKEN)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;scale.grid(row=canvasrow, column=2, sticky=&#39;NE&#39;)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;menu = tk.Menu(self.root)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;self.root.config(menu=menu)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;filemenu = tk.Menu(menu)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;editmenu = tk.Menu(menu)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;menu.add_cascade(label=&quot;File&quot;, menu=filemenu)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;menu.add_cascade(label=&quot;Edit&quot;, menu=editmenu)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;filemenu.add_command(label=&quot;New&quot;, command=NewFile)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;filemenu.add_command(label=&quot;Save as...&quot;, command=SaveAs)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;editmenu.add_command(label=&quot;About&quot;, command=About)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;def mainloop(self):&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;self.root.mainloop()&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;def NewFile():&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;tkMessageBox.showinfo(&quot;New&quot;, &quot;Creat a new file...&quot;)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;def SaveAs():&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;tkMessageBox.showinfo(&quot;Save as&quot;, &quot;Save as...&quot;)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;def About():&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;tkMessageBox.showinfo(&quot;About&quot;, &quot;This is a tkinter demo.&quot;)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;if __name__ == &#39;__main__&#39;:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;root = tk.Tk()&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;app = TKDemo(master=root)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;app.mainloop()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14.85px;&quot;&gt;以下是python&amp;nbsp; 中 Tkinter 的所有控件。大概一個2維 GUI 介面能用到的也就下方21種，非常夠用。&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ol style=&quot;background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.85px;&quot;&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Label&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Button&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Radiobutton&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Checkbutton&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Entry&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Frame&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;LabelFrame&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Listbox&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Text&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Message&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;PanedWindow&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Scrollbar&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Scale&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Spinbox&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Menu&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;OptionMenu&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Menubutton&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Canvas&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Image&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Bitmap&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Toplevel&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;h4 style=&quot;background-color: white; box-sizing: border-box; color: #2f2f2f; font-family: -apple-system, &amp;quot;SF UI Text&amp;quot;, Arial, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;WenQuanYi Micro Hei&amp;quot;, sans-serif; font-size: 20px; line-height: 1.7; margin: 0px 0px 15px; text-rendering: optimizelegibility;&quot;&gt;
&lt;/h4&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/8863788051610230123/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2019/04/python-tkinter.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/8863788051610230123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/8863788051610230123'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2019/04/python-tkinter.html' title='Python Tkinter 快速上手'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKeFRoSA6goqJ6JDRD8QXx8og_rU0R0KhtouVmrS9dUKoJdHr0Lkkx4-QBx4zggJcCFesw7InbobO9uZeyUhjOjOMU4EB0uwmlrOiF2PJ4-Of2dnIjj9CL0aD-ZtFaCIRKsP8FiIGQ_aiL/s72-c/tkinter.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-9034924706433790544</id><published>2019-04-02T01:12:00.001-07:00</published><updated>2019-04-02T01:13:43.058-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android studio"/><category scheme="http://www.blogger.com/atom/ns#" term="APP"/><title type='text'>9-Patch files 創建可調整的圖</title><content type='html'>&lt;h4 style=&quot;clear: both; text-align: left;&quot;&gt;
如何製作9-Patch的圖檔。DEVELOPER中提供了很方便的做法。&lt;/h4&gt;
&lt;h4 style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;1.先將要製作的圖檔COPY到drawable ，此例中為 123.png。然後開啟 Android Studio。(這裡小記一下，取名為123.png是不可取的。檔名需有英文字母。)點擊右鍵後，選Create 9-Patch file。&lt;/h4&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrKeg993W-nKjK8D4iJcoUoqOLs7LN857ClvfRzeXrJK4gEiCYXcT_vBeXqDdVs_BkAIYdKVPQYqPFdjjjmM22DpOhYfI2h7xVNNO-QM5g1d3igikORxRE0KnaPD4Wat806Fb5BIcvFM-T/s1600/123.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;654&quot; data-original-width=&quot;473&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrKeg993W-nKjK8D4iJcoUoqOLs7LN857ClvfRzeXrJK4gEiCYXcT_vBeXqDdVs_BkAIYdKVPQYqPFdjjjmM22DpOhYfI2h7xVNNO-QM5g1d3igikORxRE0KnaPD4Wat806Fb5BIcvFM-T/s640/123.png&quot; width=&quot;459&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h4&gt;
&amp;nbsp;2.出現尋問要將9-Patch檔存在哪裡。我們還是選drawable中。&lt;/h4&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZLL0aK9P24rNox0FTwAhEeD4zb2Ew2zHtsFx2E3s18_EXCbbq09pGiD4jIO0vUNXrW3FOq6X6AFTJczlFhWyC-AbCDXPPAG8V5CQn6tPCU0S-9LOuA7ceVx3A4cWJ0_M3I661JckQe0hY/s1600/1231.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;497&quot; data-original-width=&quot;412&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZLL0aK9P24rNox0FTwAhEeD4zb2Ew2zHtsFx2E3s18_EXCbbq09pGiD4jIO0vUNXrW3FOq6X6AFTJczlFhWyC-AbCDXPPAG8V5CQn6tPCU0S-9LOuA7ceVx3A4cWJ0_M3I661JckQe0hY/s640/1231.png&quot; width=&quot;529&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h4&gt;
3.我們會發現 drawable中已產生一個 123.9.png 檔。雙擊123.9.png。出現下圖。&lt;/h4&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRa24igOOZM7Mnk_s2mY1CKDd0pjtOQT4RPWWF_AOLexzNer2jEy3pbzsoJNjsF1RB0WVD4a9xt-fUGqR6WMw8A3vNBG7lvpGNvYHMLNrhagrWZhBBOYoepBlGpd7Nf18m4n-f3ulaFxaz/s1600/1232.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;457&quot; data-original-width=&quot;1600&quot; height=&quot;180&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRa24igOOZM7Mnk_s2mY1CKDd0pjtOQT4RPWWF_AOLexzNer2jEy3pbzsoJNjsF1RB0WVD4a9xt-fUGqR6WMw8A3vNBG7lvpGNvYHMLNrhagrWZhBBOYoepBlGpd7Nf18m4n-f3ulaFxaz/s640/1232.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h4&gt;
&amp;nbsp;4.現在是最重點的地方。拉動上下左右邊界，圖下拉完邊界，中間垂直與水平灰色區交疊區就是我們內容會放置的地方，也就是會拉伸的地方。這樣四個角落的圓弧就不會因為內容過多而變形。&lt;/h4&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiBhjkSpF42em4YM4eZfwalYk8aZs6E1gzP9vF2qG3tBBqgSMO16gBzH-flrsXfpNTBjq874agTQ1-T71XUc5WaluewIlBletJjZcl-tgZZig8R2x832brSrO5W56NGoEx8QfD4n4SYvy6/s1600/1233.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;508&quot; data-original-width=&quot;1375&quot; height=&quot;232&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiBhjkSpF42em4YM4eZfwalYk8aZs6E1gzP9vF2qG3tBBqgSMO16gBzH-flrsXfpNTBjq874agTQ1-T71XUc5WaluewIlBletJjZcl-tgZZig8R2x832brSrO5W56NGoEx8QfD4n4SYvy6/s640/1233.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h4&gt;
5.存檔，原本的123.png可以移除。程式中使用圖檔時，只需用到檔名 123，後面的.9可以不加。&lt;/h4&gt;
</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/9034924706433790544/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2019/04/9-patch-files.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/9034924706433790544'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/9034924706433790544'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2019/04/9-patch-files.html' title='9-Patch files 創建可調整的圖'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrKeg993W-nKjK8D4iJcoUoqOLs7LN857ClvfRzeXrJK4gEiCYXcT_vBeXqDdVs_BkAIYdKVPQYqPFdjjjmM22DpOhYfI2h7xVNNO-QM5g1d3igikORxRE0KnaPD4Wat806Fb5BIcvFM-T/s72-c/123.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-2673372350997546322</id><published>2019-03-30T09:00:00.002-07:00</published><updated>2019-03-30T09:00:39.868-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="APP"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><title type='text'>Screen Size 螢幕尺寸 與 文字大小</title><content type='html'>&lt;code1&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DisplayMetrics dm=new DisplayMetrics();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getWindowManager().getDefaultDisplay().getMetrics(dm);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; displayWidth=dm.widthPixels;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; displayHeight=dm.heightPixels;&lt;br /&gt;
&lt;/code1&gt;
&lt;br /&gt;
用這個方法我們可以得到螢幕的尺寸。有了螢幕的尺寸，我們就可以設定文字的大小，讓文字大小跟著螢幕尺寸改變。

&lt;br /&gt;

&lt;br /&gt;&lt;code1&gt;
int contentWordSize=11; //一列11個字。
TextView tv=findViewById(R.id.xxxx);
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, displayWidth/contentWordSize);
&lt;/code1&gt;
&lt;br /&gt;
這樣是不是很方便！</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/2673372350997546322/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2019/03/screen-size.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/2673372350997546322'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/2673372350997546322'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2019/03/screen-size.html' title='Screen Size 螢幕尺寸 與 文字大小'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-6018258665485157202</id><published>2019-03-30T08:49:00.000-07:00</published><updated>2019-03-30T08:49:26.525-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="APP"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><title type='text'>改變 drawable 的顏色</title><content type='html'>&lt;code1&gt;
public static Drawable tintDrawable(Drawable drawable, int color) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Drawable wd = DrawableCompat.wrap(drawable);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DrawableCompat.setTint(wd, color);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return wd;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;/code1&gt;&lt;br /&gt;

&lt;br /&gt;
只要將使用中的drawable，用上面的方法處理，再拿來用，drawable的顏色就會改變。
這個方法可以用來處理ImageButton點擊後，ImageButton變色。方便許多。
&lt;br /&gt;
&lt;br /&gt;
&lt;code1&gt;
ImageButton ibtn = findViewById(&lt;span style=&quot;color: red;&quot;&gt;R.id.xxxx&lt;/span&gt;);
iBtn.setBackground(getResources().getDrawable(R&lt;span style=&quot;color: red;&quot;&gt;.drawable.xxxx&lt;/span&gt;));

ibtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               ibtn.setBackground(tintDrawable(getResources().getDrawable(&lt;span style=&quot;color: red;&quot;&gt;R.drawable.xxxx&lt;/span&gt;)&lt;span style=&quot;color: blue;&quot;&gt;.mutate()&lt;/span&gt;, &lt;span style=&quot;color: red;&quot;&gt;Color.Green&lt;/span&gt;));

               new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() { 
                        iBtn.setBackground(getResources().getDrawable(R&lt;span style=&quot;color: red;&quot;&gt;.drawable.xxxx&lt;/span&gt;));

                  
                    }
                }, 1000); 
            }
        });
&lt;/code1&gt;
&lt;br /&gt;
&lt;br /&gt;
現在ImageButton點擊後，會將原來的圖變成Color.GREEN的顏色，然後我們利用Handler，將原本未變色的ImageButton的圖再設定一次，就可以制造點擊時顏色按鈕顏色的改變了。&lt;br /&gt;
&lt;br /&gt;
紅色標記的文字請自行修改。這裡有一個重點，藍色標記的mutate()代表這張圖的改變不影響其它也用到此張圖的物件。也就是說，如果沒有mutate()，其它用這張圖的物件也都會變成color.GREEN了。那麼，我們在handler中設置原圖就不起作用，因為原圖已經被Color.GREEN了，我們只是把被Color.GREEN過的圖再一次設為背景而以。&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/6018258665485157202/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2019/03/drawable.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/6018258665485157202'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/6018258665485157202'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2019/03/drawable.html' title='改變 drawable 的顏色'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-2952270659763666040</id><published>2019-03-18T20:05:00.001-07:00</published><updated>2019-03-30T08:59:32.476-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="APP"/><title type='text'>PendingIntent 速記</title><content type='html'>什麼是PendingIntent，字面上來看就是 即將發生的intent。&lt;br /&gt;
&lt;br /&gt;
我們知道如果要開始一個Intent，可以如下&lt;br /&gt;
&lt;br /&gt;
Intent x1 = new Intent( this, xxx.class);&lt;br /&gt;
startActivity(x1);&lt;br /&gt;
&lt;br /&gt;
通常我們是要開啟一個新的activity會用到Intent。我們更應該把 Intent理解為Activity間的一個訊息的傳遞。也就是由Intent這個信使，帶著訊息，告知Activity要啟動了。這樣理解，我們可以推論，Intent可以帶著訊息通知其它class，讓他們啟動。&lt;br /&gt;
&lt;br /&gt;
如 Service&lt;br /&gt;
Intent x1 = new Intent(this, xxxService.class);&lt;br /&gt;
startService(x1);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
但有時候，我們有一個Intent，我們不想用 startActivity, 或是 startService去啟動，而是希望它等待至某種要求出現才啟動。這就需要用到 PendingIntent。&lt;br /&gt;
&lt;br /&gt;
所以簡單的說，PendingIntent就是把一個已知的 Intent 包起來。然後pending(即將發生)。&lt;br /&gt;
我們看一下PendingIntent有幾個靜態方法&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;包了一個Activity的Intent&lt;/span&gt;&lt;br /&gt;
public static PendingIntent getActivity(Context context, int requestCode, Intent intent, int flags)&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;包了一個Broadcast的Intent&lt;/span&gt;&lt;br /&gt;
public static PendingIntent getBroadcast(Context context, int requestCode, Intent intent, int flags)&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;包了一個Service的Intent&lt;/span&gt;&lt;br /&gt;
public static PendingIntent getService(Context context, int requestCode, Intent intent, int flags)&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;包了多個Activity的Intent&lt;/span&gt;&lt;br /&gt;
public static PendingIntent getActivities(Context context, int requestCode, Intent[] intents, int flags)&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;包了多個Activity的Intent 加上 Bundle。&lt;/span&gt;&lt;br /&gt;
public static PendingIntent getActivities(Context context, int requestCode, Intent[] intents, int flags, Bundle options)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
這樣我們就能理解，為什麼Notification會需要用到PendingIntent。因為這個Pending(即將發生)，是由Notification來觸發。以下我們看一個Notification的範例。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;code1&gt;

 if (Build.VERSION.SDK_INT &amp;gt;= Build.VERSION_CODES.O) {
    CharSequence name = &quot;&lt;span style=&quot;color: red;&quot;&gt;自己設一個名字&lt;/span&gt;&quot;;
    String description =&quot;&lt;span style=&quot;color: red;&quot;&gt;自己描述一下是什麼Notification&lt;/span&gt;&quot;;
    int importance = NotificationManager.IMPORTANCE_DEFAULT;
    NotificationChannel channel = new NotificationChannel(&quot;&lt;span style=&quot;color: red;&quot;&gt;這是CHANNEL ID，自己設&lt;/span&gt;&quot;, name, importance);
    channel.setDescription(description);
    // Register the channel with the system; you can&#39;t change the importance
    // or other notification behaviors after this
    mNManager = getSystemService(NotificationManager.class);
    mNManager.createNotificationChannel(channel);
}else {
    mNManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
 }

   Intent x1 = new Intent (context, xxxActivity.class);
   x1.putExtra(&quot;str&quot;, &quot;&lt;span style=&quot;color: red;&quot;&gt;自帶文字&lt;/span&gt;&quot;);
   &lt;span style=&quot;color: red;&quot;&gt;PendingIntent pX1 = PendingIntent.getActivity(context, 0, x1, PendingIntent.FLAG_CANCEL_CURRENT);&lt;/span&gt;


   Notification.Builder mBuilder = new Notification.Builder(context);
   mBuilder.setContentTitle(getResources().getString(&lt;span style=&quot;color: red;&quot;&gt;R.string.XXXXX&lt;/span&gt;))  //標題
                .setContentText(&lt;span style=&quot;color: red;&quot;&gt;自己設的文字&lt;/span&gt;&quot;)      //內容
                .setSubText(&quot;&lt;span style=&quot;color: red;&quot;&gt;自己設的文字&lt;/span&gt;&quot;)        //内容下面一小段註明
                .setTicker(&quot;&lt;span style=&quot;color: red;&quot;&gt;自己設的文字&lt;/span&gt;&quot;)          //狀態欄顯示的文字
                .setWhen(System.currentTimeMillis())           //時間
                .setSmallIcon( &lt;span style=&quot;color: red;&quot;&gt;R.drawable.XXXX&lt;/span&gt;)            //狀態欄之小圖
                //.setLargeIcon(&lt;span style=&quot;color: red;&quot;&gt; R.drawable.xxxx&lt;/span&gt;)          //大圖
                .setDefaults(Notification.DEFAULT_LIGHTS )    //設置提醒通知
                .setAutoCancel(true)                           //點擊後是否消失
                &lt;span style=&quot;color: red;&quot;&gt;.setContentIntent(pX1);             //點擊後啟動 PendingIntent&lt;/span&gt; 
           
   notify1 = mBuilder.build();
   mNManager.notify(1, notify1);
&lt;/code1&gt;

&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/2952270659763666040/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2019/03/pendingintent.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/2952270659763666040'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/2952270659763666040'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2019/03/pendingintent.html' title='PendingIntent 速記'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-6761057468929900742</id><published>2019-03-05T00:35:00.001-08:00</published><updated>2019-03-05T00:35:21.324-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android memo"/><title type='text'>Android 自動產生 VIEW ID</title><content type='html'>動態產生 Layout 時一定會遇到 ID配置的問題。&lt;br /&gt;
在API &amp;gt; 17後有提供一個&amp;nbsp;&lt;span style=&quot;background-color: #f8f8f8; color: inherit; font-family: &amp;quot;Source Code Pro&amp;quot;, monospace; font-size: inherit;&quot;&gt;View.generateViewId()，只要在新增的LAYOUT物件設定即可&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Button btn = new Button(this);&lt;br /&gt;
btn.setId(View.generateViewId());&lt;br /&gt;
&lt;br /&gt;
如果需要API&amp;lt;17要如何是好？我們深入View.generateViewId()看看。&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;hljs java&quot; style=&quot;background: rgb(248, 248, 248); border-color: rgb(204, 204, 204) rgb(204, 204, 204) rgb(204, 204, 204) rgb(153, 153, 153); border-image: initial; border-style: solid; border-width: 1px 1px 1px 3px; box-sizing: border-box; color: #333333; direction: ltr; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; margin-bottom: 1rem; margin-top: 1rem; overflow-wrap: break-word; overflow: auto; padding: 0.5em;&quot;&gt;&lt;code style=&quot;box-sizing: border-box; color: inherit; font-family: &amp;quot;Source Code Pro&amp;quot;, monospace; font-size: inherit; margin-left: 0.25rem; margin-right: 0.25rem; overflow-wrap: break-word; word-break: normal;&quot;&gt;
    &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;final&lt;/span&gt; AtomicInteger sNextGeneratedId = &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;new&lt;/span&gt; AtomicInteger(&lt;span class=&quot;hljs-number&quot; style=&quot;box-sizing: border-box; color: teal; overflow-wrap: break-word;&quot;&gt;1&lt;/span&gt;);

  
    &lt;span class=&quot;hljs-function&quot; style=&quot;box-sizing: border-box; overflow-wrap: break-word;&quot;&gt;&lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-title&quot; style=&quot;box-sizing: border-box; color: #990000; font-weight: bold; overflow-wrap: break-word;&quot;&gt;generateViewId&lt;/span&gt;&lt;span class=&quot;hljs-params&quot; style=&quot;box-sizing: border-box; overflow-wrap: break-word;&quot;&gt;()&lt;/span&gt; &lt;/span&gt;{

            &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;for&lt;/span&gt; (;;) {
                &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;int&lt;/span&gt; result = sNextGeneratedId.get();
                &lt;span class=&quot;hljs-comment&quot; style=&quot;box-sizing: border-box; color: #999988; font-style: italic; overflow-wrap: break-word;&quot;&gt;// aapt-generated IDs have the high byte nonzero; clamp to the range under that.&lt;/span&gt;
                &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;int&lt;/span&gt; newValue = result + &lt;span class=&quot;hljs-number&quot; style=&quot;box-sizing: border-box; color: teal; overflow-wrap: break-word;&quot;&gt;1&lt;/span&gt;;
                &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;if&lt;/span&gt; (newValue &amp;gt; &lt;span class=&quot;hljs-number&quot; style=&quot;box-sizing: border-box; color: teal; overflow-wrap: break-word;&quot;&gt;0x00FFFFFF&lt;/span&gt;)
                    newValue = &lt;span class=&quot;hljs-number&quot; style=&quot;box-sizing: border-box; color: teal; overflow-wrap: break-word;&quot;&gt;1&lt;/span&gt;; &lt;span class=&quot;hljs-comment&quot; style=&quot;box-sizing: border-box; color: #999988; font-style: italic; overflow-wrap: break-word;&quot;&gt;// Roll over to 1, not 0.&lt;/span&gt;
                &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;if&lt;/span&gt; (sNextGeneratedId.compareAndSet(result, newValue)) {
                    &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;return&lt;/span&gt; result;
                }
            }
        }

  
&lt;/code&gt;&lt;/pre&gt;
看樣子，是用AtomicInteger來增加ID。利用compareAndSet(CAS)來查newValue是否可以置入result的記憶體位址中。另外我們也看到，newValue最高到0x00FFFFFF，0x00FFFFFF以上就會從1再開始。也代表0x00FFFFFF以上是保留給系統工具使用。&lt;br /&gt;
&lt;br /&gt;
所以，generateViewID()的步驟就是&lt;br /&gt;
1.先得到目前ID&lt;br /&gt;
2.目前ID加1&lt;br /&gt;
3.檢查是否大於0x00FFFFFF，如果是就重置為1&lt;br /&gt;
4.檢查記憶體中的值是否已被改變。如無，得把newValue寫入result的記憶體位址中。如有，則下一個迴圈。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
那麼我們小改一下，讓API &amp;lt; 17也可使用。如下&lt;br /&gt;
&lt;pre class=&quot;hljs java&quot; style=&quot;background: rgb(248, 248, 248); border-color: rgb(204, 204, 204) rgb(204, 204, 204) rgb(204, 204, 204) rgb(153, 153, 153); border-image: initial; border-style: solid; border-width: 1px 1px 1px 3px; box-sizing: border-box; color: #333333; direction: ltr; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; margin-bottom: 1rem; margin-top: 1rem; overflow-wrap: break-word; overflow: auto; padding: 0.5em;&quot;&gt;&lt;code style=&quot;box-sizing: border-box; color: inherit; font-family: &amp;quot;Source Code Pro&amp;quot;, monospace; font-size: inherit; margin-left: 0.25rem; margin-right: 0.25rem; overflow-wrap: break-word; word-break: normal;&quot;&gt;&lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-class&quot; style=&quot;box-sizing: border-box; overflow-wrap: break-word;&quot;&gt;&lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title&quot; style=&quot;box-sizing: border-box; color: #445588; font-weight: bold; overflow-wrap: break-word;&quot;&gt;ViewIdGenerator&lt;/span&gt; &lt;/span&gt;{
    &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;final&lt;/span&gt; AtomicInteger sNextGeneratedId = &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;new&lt;/span&gt; AtomicInteger(&lt;span class=&quot;hljs-number&quot; style=&quot;box-sizing: border-box; color: teal; overflow-wrap: break-word;&quot;&gt;1&lt;/span&gt;);

    &lt;span class=&quot;hljs-function&quot; style=&quot;box-sizing: border-box; overflow-wrap: break-word;&quot;&gt;&lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-title&quot; style=&quot;box-sizing: border-box; color: #990000; font-weight: bold; overflow-wrap: break-word;&quot;&gt;generateViewId&lt;/span&gt;&lt;span class=&quot;hljs-params&quot; style=&quot;box-sizing: border-box; overflow-wrap: break-word;&quot;&gt;()&lt;/span&gt; &lt;/span&gt;{

        &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;if&lt;/span&gt; (Build.VERSION.SDK_INT &amp;lt; &lt;span class=&quot;hljs-number&quot; style=&quot;box-sizing: border-box; color: teal; overflow-wrap: break-word;&quot;&gt;17&lt;/span&gt;) {
            &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;for&lt;/span&gt; (;;) {
                &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;int&lt;/span&gt; result = sNextGeneratedId.get();
                &lt;span class=&quot;hljs-comment&quot; style=&quot;box-sizing: border-box; color: #999988; font-style: italic; overflow-wrap: break-word;&quot;&gt;// aapt-generated IDs have the high byte nonzero; clamp to the range under that.&lt;/span&gt;
                &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;int&lt;/span&gt; newValue = result + &lt;span class=&quot;hljs-number&quot; style=&quot;box-sizing: border-box; color: teal; overflow-wrap: break-word;&quot;&gt;1&lt;/span&gt;;
                &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;if&lt;/span&gt; (newValue &amp;gt; &lt;span class=&quot;hljs-number&quot; style=&quot;box-sizing: border-box; color: teal; overflow-wrap: break-word;&quot;&gt;0x00FFFFFF&lt;/span&gt;)
                    newValue = &lt;span class=&quot;hljs-number&quot; style=&quot;box-sizing: border-box; color: teal; overflow-wrap: break-word;&quot;&gt;1&lt;/span&gt;; &lt;span class=&quot;hljs-comment&quot; style=&quot;box-sizing: border-box; color: #999988; font-style: italic; overflow-wrap: break-word;&quot;&gt;// Roll over to 1, not 0.&lt;/span&gt;
                &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;if&lt;/span&gt; (sNextGeneratedId.compareAndSet(result, newValue)) {
                    &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;return&lt;/span&gt; result;
                }
            }
        } &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;else&lt;/span&gt; {
            &lt;span class=&quot;hljs-keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold; overflow-wrap: break-word;&quot;&gt;return&lt;/span&gt; View.generateViewId();
        }

    }
}&lt;/code&gt;&lt;/pre&gt;
這個解決方案很不錯。&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/6761057468929900742/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2019/03/android-view-id.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/6761057468929900742'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/6761057468929900742'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2019/03/android-view-id.html' title='Android 自動產生 VIEW ID'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-8212903707923088700</id><published>2019-02-01T19:35:00.001-08:00</published><updated>2019-02-01T19:59:06.127-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android studio"/><category scheme="http://www.blogger.com/atom/ns#" term="APP"/><title type='text'>Android AudioTrack AudioRecord II</title><content type='html'>上一篇寫一半，我們把他完善了，針對AudioRecord的部份
&lt;code1&gt;
new Thread(new Runnable() {
&amp;nbsp; @Override
&amp;nbsp; public void run() {
&amp;nbsp; &amp;nbsp; int recBuffSize=AudioRecord.getMinBufferSize(SAMPLE_RATE, AudioFormat.CHANNEL_IN_STEREO, AudioFormat.ENCODING_PCM_16BIT);
&amp;nbsp; &amp;nbsp; //recBuffSize = 4096;&lt;span style=&quot;color: red;&quot;&gt;//如果語音斷斷續續可以調整buffer size&lt;/span&gt;
&amp;nbsp; &amp;nbsp; AudioRecord audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC, SAMPLE_RATE, AudioFormat.CHANNEL_IN_STEREO, AudioFormat.ENCODING_PCM_16BIT, recBuffSize);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&amp;nbsp; &amp;nbsp; byte[] buffer = new byte[recBuffSize];
&amp;nbsp; &amp;nbsp; audioRecord.startRecording(); // 开始录音
&amp;nbsp; &amp;nbsp; try {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; clientSocket = new DatagramSocket();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; } catch (SocketException e) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; e.printStackTrace();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; InetAddress des = null;
&amp;nbsp; &amp;nbsp; try {
&amp;nbsp; &amp;nbsp; &amp;nbsp; des = InetAddress.getByName(&quot;192.168.1.XX&quot;);
&amp;nbsp; &amp;nbsp; } catch (UnknownHostException e) {
&amp;nbsp; &amp;nbsp; &amp;nbsp; e.printStackTrace();
&amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; int port = 3333;
&amp;nbsp; &amp;nbsp; while (true) {
&amp;nbsp; &amp;nbsp; &amp;nbsp; int bufferReadResult = audioRecord.read(buffer, 0, recBuffSize);
&amp;nbsp; &amp;nbsp; &amp;nbsp; packet = new DatagramPacket(buffer, buffer.length, des, port);
&amp;nbsp; &amp;nbsp; &amp;nbsp; try {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; clientSocket.send(packet);
&amp;nbsp; &amp;nbsp; &amp;nbsp; } catch (Exception e) {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Log.d(&quot;UDP SEND&quot;, &quot;udp send data fail&quot;)
&amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; audioRecord.stop();
&amp;nbsp; &amp;nbsp; audioRecord.release();
&amp;nbsp; }
}).start();
&lt;/code1&gt; 

如果不編譯有問題，記得檢查是否有把權限打開在 AndroidManifest.xml
&lt;code1&gt;
&amp;lt;uses-permission android:name=&quot;android.permission.INTERNET&quot;&amp;gt;
&amp;lt;uses-permission android:name=&quot;android.permission.WAKE_LOCK&quot;&amp;gt;
&amp;lt;uses-permission android:name=&quot;android.permission.RECORD_AUDIO&quot;&amp;gt;
&lt;/code1&gt; 

android 8.0以上，要詢問使用者
&lt;code1&gt;
if (Build.VERSION.SDK_INT &amp;gt;= Build.VERSION_CODES.M) {
&amp;nbsp; if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) ==PackageManager.PERMISSION_GRANTED) {
&amp;nbsp; &amp;nbsp; // put your code for Version&amp;gt;=Marshmallow
&amp;nbsp; } else {
&amp;nbsp; &amp;nbsp; if (shouldShowRequestPermissionRationale(Manifest.permission.RECORD_AUDIO)) {
&amp;nbsp; &amp;nbsp; &amp;nbsp;Toast.makeText(this,&quot;App required access to audio&quot;, Toast.LENGTH_SHORT).show();
&amp;nbsp; }
&amp;nbsp; requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, &lt;span style=&quot;color: red;&quot;&gt;回傳碼&lt;/span&gt;);
}

&lt;/code1&gt;
上一篇AudioTrack的udp資接收就可以改成
&lt;code1&gt;
byte[] receiveData = new byte[4096];
DatagramPacket packet = new DatagramPacket(receiveData, receiveData.length); 
int port  = 3333;           
try {
&amp;nbsp; serverSocket = new DatagramSocket(port);
} catch (SocketException e) {
&amp;nbsp; e.printStackTrace();
}
while (true) {
&amp;nbsp; try {
&amp;nbsp; &amp;nbsp; serverSocket.receive(packet);
&amp;nbsp; &amp;nbsp; byte[] b = packet.getData();
&amp;nbsp; &amp;nbsp; audioTrack.write(b, 0, b.length);
&amp;nbsp; } catch (Exception e) {
&amp;nbsp; &amp;nbsp; Log.d(&quot;UDP GET&quot;, &quot;udp get data fail&quot;)
&amp;nbsp; }
}
&lt;/code1&gt;</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/8212903707923088700/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2019/02/android-audiotrack-audiorecord-ii.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/8212903707923088700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/8212903707923088700'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2019/02/android-audiotrack-audiorecord-ii.html' title='Android AudioTrack AudioRecord II'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-2168703186232426087</id><published>2019-01-30T00:40:00.001-08:00</published><updated>2019-01-30T22:15:56.615-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android studio"/><category scheme="http://www.blogger.com/atom/ns#" term="APP"/><title type='text'>Android AudioTrack AudioRecord</title><content type='html'>如何使用 AudioTrack，其實跟AudioRecord差不多, 我們做一個比較&lt;br /&gt;
&lt;br /&gt;
新增一個AudioTrack 跟新增一個AudioRecord幾乎一樣&lt;br /&gt;
&lt;br /&gt;
&lt;code1&gt;&lt;br /&gt;
AudioTrack audioTrack = new AudioTrack(&lt;br /&gt;
AudioManager.STREAM_MUSIC,&lt;br /&gt;
SAMPLE_RATE,&lt;br /&gt;
AudioFormat.CHANNEL_OUT_MONO,&lt;br /&gt;
AudioFormat.ENCODING_PCM_16BIT,&lt;br /&gt;
bufferSize,&lt;br /&gt;
AudioTrack.MODE_STREAM);&lt;br /&gt;
&lt;/code1&gt;&lt;br /&gt;
以下是AudioRecord&lt;br /&gt;
&lt;code1&gt;&lt;br /&gt;
AudioRecord record = new AudioRecord(&lt;br /&gt;
MediaRecorder.AudioSource.DEFAULT,&lt;br /&gt;
SAMPLE_RATE,&lt;br /&gt;
AudioFormat.CHANNEL_IN_MONO,&lt;br /&gt;
AudioFormat.ENCODING_PCM_16BIT,&lt;br /&gt;
bufferSize);&lt;br /&gt;
&lt;/code1&gt;&lt;br /&gt;
AudioTrack多了AudioTrack.MODE_STREAM這個選項。AudioTrack.MODE_STREAM是指串流的資料。AudioTrack.MODE_STATIC是指一次把整個音源檔載入。&lt;br /&gt;
&lt;br /&gt;
兩個類都有bufferSize這個參數。bufferSize 是需要計算的，也可能跟手機的硬體能力有關。所以兩個類都有提供計算的方法。&lt;br /&gt;
&lt;br /&gt;
&lt;code1&gt;&lt;br /&gt;
int bufferSize = AudioRecord.getMinBufferSize(&lt;br /&gt;
SAMPLE_RATE,&lt;br /&gt;
AudioFormat.CHANNEL_IN_MONO,&lt;br /&gt;
AudioFormat.ENCODING_PCM_16BIT);&lt;br /&gt;
&lt;br /&gt;
int bufferSize = AudioTrack.getMinBufferSize(&lt;br /&gt;
SAMPLE_RATE, &lt;br /&gt;
AudioFormat.CHANNEL_OUT_MONO,&lt;br /&gt;
AudioFormat.ENCODING_PCM_16BIT);&lt;br /&gt;
&lt;/code1&gt;&lt;br /&gt;
&lt;br /&gt;
這樣我們可以建一個Thread來讓AudioTrack播串流音樂&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;code1&gt;&lt;br /&gt;
void playMusic() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; new Thread(new Runnable() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; @Override&lt;br /&gt;
&amp;nbsp; &amp;nbsp; public void run() {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int bufferSize = AudioTrack.getMinBufferSize(&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SAMPLE_RATE,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AudioFormat.CHANNEL_OUT_MONO,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AudioFormat.ENCODING_PCM_16BIT);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (bufferSize == AudioTrack.ERROR || bufferSize == AudioTrack.ERROR_BAD_VALUE) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bufferSize = SAMPLE_RATE * 2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AudioTrack audioTrack = new AudioTrack(&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AudioManager.STREAM_MUSIC,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SAMPLE_RATE,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AudioFormat.CHANNEL_OUT_MONO,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AudioFormat.ENCODING_PCM_16BIT,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bufferSize,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AudioTrack.MODE_STREAM);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; audioTrack.setStereoVolume(1.0f, 1.0f);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; audioTrack.play();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while (true) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: red;&quot;&gt;byte[] buffer = packet.getData();//如果資料從udp來&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;audioTrack.write(buffer, 0, buffer.length);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; audioTrack.stop();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; audioTrack.release();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
}).start();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;/code1&gt;</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/2168703186232426087/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2019/01/android-audiotrack-audiorecord.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/2168703186232426087'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/2168703186232426087'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2019/01/android-audiotrack-audiorecord.html' title='Android AudioTrack AudioRecord'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-3459994765038040378</id><published>2019-01-28T23:12:00.002-08:00</published><updated>2019-01-30T22:15:44.364-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>python 找圖自動點擊</title><content type='html'>需要 import 這幾個 module&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
import cv2&lt;/div&gt;
&lt;div&gt;
import numpy as np&lt;/div&gt;
&lt;div&gt;
import pyautogui&lt;/div&gt;
&lt;div&gt;
import time&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
滑鼠點擊&lt;/div&gt;
&lt;code1&gt;&lt;br /&gt;
&lt;/code1&gt;&lt;br /&gt;
&lt;div&gt;
def click_image(image,pos,&amp;nbsp; action, timestamp,offset=5):&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; img = cv2.imread(image)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; height, width, channels = img.shape&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; pyautogui.moveTo(pos[0] + offset, pos[1] + ,offset, timestamp)&lt;/div&gt;
&amp;nbsp; &amp;nbsp; pyautogui.click(button=action)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
圖片尋找&lt;br /&gt;
&lt;code1&gt;&lt;br /&gt;
def imagesearch(image, precision=0.8):&lt;br /&gt;
&amp;nbsp; &amp;nbsp; im = pyautogui.screenshot()&lt;br /&gt;
&amp;nbsp; &amp;nbsp; img_rgb = np.array(im)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; template = cv2.imread(image, 0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; template.shape[::-1]&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; res = cv2.matchTemplate(img_gray, template, cv2.TM_CCOEFF_NORMED)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if max_val &amp;lt; precision:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return [-1,-1]&lt;br /&gt;
&amp;nbsp; &amp;nbsp; return max_loc&lt;span style=&quot;color: red;&quot;&gt; #返回圖片座標&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/code1&gt;&lt;br /&gt;
&lt;br /&gt;
使用方式&lt;br /&gt;
&lt;code1&gt;&lt;br /&gt;
if __name__ == &#39;__main__&#39;:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; pp =imagesearch(&quot;./1.png&quot;)&lt;span style=&quot;color: red;&quot;&gt;#尋找1.png的圖。(把圖跟程式放同一個目錄下)&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; click_image(&quot;./1.png&quot;, pp, &quot;left&quot;, 1)&lt;span style=&quot;color: red;&quot;&gt; #要點右鍵的話，就把&quot;left&quot;改成 &quot;right&quot;, 最後的參數1，代表滑鼠移動到目標的時候。設越長，滑鼠移動越慢。&lt;/span&gt;&lt;/code1&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://github.com/drov0/python-imagesearch/blob/master/imagesearch.py&quot;&gt;imagesearch.py&lt;/a&gt;&amp;nbsp;&amp;lt; ---這裡有完整的檔。佛心！</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/3459994765038040378/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2019/01/python.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/3459994765038040378'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/3459994765038040378'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2019/01/python.html' title='python 找圖自動點擊'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-4571420450267153993</id><published>2019-01-26T07:46:00.003-08:00</published><updated>2019-01-26T07:46:50.483-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ubuntu"/><title type='text'>升級 ubuntu 後 terminal 無法打開</title><content type='html'>&lt;h4 style=&quot;text-align: center;&quot;&gt;
解決方法&lt;/h4&gt;
&lt;br /&gt;
試幾個方法，重開機就好，也不知哪一招有效。紀綠如下&lt;br /&gt;
&lt;br /&gt;
先下載一個 knosole 當暫時的 terminal&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: center;&quot;&gt;
第一招&lt;/h4&gt;
把原本的 .bashrc 先備份一下，砍了。重開機再開terminal看看。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: center;&quot;&gt;
第二招&lt;/h4&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;sudo locale-gen --purge&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt; &lt;/code&gt;
&lt;code&gt;重開機再開terminal看看。&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;不行的話，再試試&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&lt;code&gt;sudo locale-gen&lt;/code&gt; &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&lt;code class=&quot;hljs shell&quot; data-lang=&quot;&quot;&gt;&lt;span class=&quot;bash&quot;&gt;sudo localectl &lt;span class=&quot;hljs-built_in&quot;&gt;set&lt;/span&gt;-locale LANG=&lt;span class=&quot;hljs-string&quot;&gt;&quot;en_US.UTF-8&quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&amp;nbsp;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;
&lt;code&gt;&lt;code&gt;重開機再開terminal看看。&lt;/code&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;h4&gt;
&lt;code&gt;第三招&lt;/code&gt;&lt;/h4&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;code&gt;&lt;code&gt;sudo apt remove chrome-remote-desktop&lt;/code&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&lt;code&gt;&lt;code&gt;重開機再開terminal看看。&lt;/code&gt;&amp;nbsp;&lt;/code&gt; &lt;/code&gt;&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/4571420450267153993/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2019/01/ubuntu-terminal.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/4571420450267153993'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/4571420450267153993'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2019/01/ubuntu-terminal.html' title='升級 ubuntu 後 terminal 無法打開'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3822675434782806040.post-5526147060758515028</id><published>2019-01-22T00:49:00.001-08:00</published><updated>2019-01-23T01:01:15.058-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Python  讀 EXCEL</title><content type='html'>先&lt;br /&gt;
from xlrd import open_workbook&lt;br /&gt;
&lt;br /&gt;
開放excel檔 a.xlsx&lt;br /&gt;
&lt;br /&gt;
wk = open_workbook(&#39;a.xlsx&#39;)&lt;br /&gt;
&lt;br /&gt;
查看有哪些sheet&lt;br /&gt;
&lt;br /&gt;
for s in wk.sheets():&lt;br /&gt;
&amp;nbsp; &amp;nbsp; print &quot;Sheet: $s has cols: $s and rows: $s&quot; % (s.name, s.ncols, s.nrows)&lt;br /&gt;
&lt;br /&gt;
讀第一個sheet 的每一列的資料&lt;br /&gt;
&lt;br /&gt;
for r in range(wk.sheets()[0].nrows):&lt;br /&gt;
&amp;nbsp; &amp;nbsp; print wk.sheets()[0].cell_value(r, 3) #第4欄&lt;br /&gt;
&amp;nbsp; &amp;nbsp; print wk.sheets()[0].cell_value(r, 5) #第6欄&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
如果遇到合併格&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAdN_cbAGlaWy0o5vmxe_hzS_mXQobyVWX1wqt__XEjzJFvPoCHpuTjipxOF0FXaX94RLJRfGOh6TG28Kd-UopMWslrBxyC4WwUwMmycqwtnF_4x90Ju09Fiarlr8eTSf-3AlO_TK7Kg9D/s1600/1548233267770.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;460&quot; data-original-width=&quot;328&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAdN_cbAGlaWy0o5vmxe_hzS_mXQobyVWX1wqt__XEjzJFvPoCHpuTjipxOF0FXaX94RLJRfGOh6TG28Kd-UopMWslrBxyC4WwUwMmycqwtnF_4x90Ju09Fiarlr8eTSf-3AlO_TK7Kg9D/s640/1548233267770.jpg&quot; width=&quot;449&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
s = wk.sheets()[0]&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
table = s.merged_cells&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
merCell = {}&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
for r in range(s.nrows):&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; for t in table:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if r&amp;gt;=t[0] and r&amp;lt; t[1]:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if s.cell_value(r,0) != &quot;&quot;:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; merCells[t] = s.cell_value(r,0)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
因為s.merged_cells會給出，sheet中所有合併格範圍的list如下&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
[(1, 8, 0, 1), (48, 56, 0, 1), (39, 45, 0, 1), (8, 32, 0, 1), (45, 48, 0, 1), (85, 93, 0, 1), (93, 109, 0, 1), (56, 64, 0, 1), (83, 85, 0, 1), (32, 38, 0, 1), (77, 83, 0, 1), (64, 73, 0, 1), (73, 77, 0, 1)]&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
以第一個元素 (1,8,0,1)是指這個合併格的 row 是&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;lt;= row &amp;lt; 8 , 0&amp;lt;=col &amp;lt; 1這個範圍。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
所以我們做一個字典，merCell。以merged_cells的元素為key。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
上面的結果就會 print merCells 就會看到&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
{(85, 93, 0, 1): u&#39;Lta&#39;, (8, 32, 0, 1): u&#39;LTb&#39;,...}&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
之後只要檢驗列與欄是否在合併格範圍，就可以查merCells得到要的值。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
如此這般即可處理</content><link rel='replies' type='application/atom+xml' href='http://my2drhapsody.blogspot.com/feeds/5526147060758515028/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://my2drhapsody.blogspot.com/2019/01/python-excel.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/5526147060758515028'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3822675434782806040/posts/default/5526147060758515028'/><link rel='alternate' type='text/html' href='http://my2drhapsody.blogspot.com/2019/01/python-excel.html' title='Python  讀 EXCEL'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAdN_cbAGlaWy0o5vmxe_hzS_mXQobyVWX1wqt__XEjzJFvPoCHpuTjipxOF0FXaX94RLJRfGOh6TG28Kd-UopMWslrBxyC4WwUwMmycqwtnF_4x90Ju09Fiarlr8eTSf-3AlO_TK7Kg9D/s72-c/1548233267770.jpg" height="72" width="72"/><thr:total>0</thr:total></entry></feed>