锘??xml version="1.0" encoding="utf-8" standalone="yes"?>欧美激情精品久久久久久变态,亚洲三级性片,欧美一区二区三区免费大片http://www.shnenglu.com/guijie/category/21368.html鏉板摜濂?鍝堝搱!zh-cnSat, 05 Sep 2020 14:27:37 GMTSat, 05 Sep 2020 14:27:37 GMT60[zz] Python3涓璸rint()鍑芥暟杈撳嚭澶氫釜鍙橀噺http://www.shnenglu.com/guijie/archive/2020/09/05/217438.html鏉板摜鏉板摜Sat, 05 Sep 2020 00:44:00 GMThttp://www.shnenglu.com/guijie/archive/2020/09/05/217438.htmlhttp://www.shnenglu.com/guijie/comments/217438.htmlhttp://www.shnenglu.com/guijie/archive/2020/09/05/217438.html#Feedback0http://www.shnenglu.com/guijie/comments/commentRss/217438.htmlhttp://www.shnenglu.com/guijie/services/trackbacks/217438.html絎竴縐嶆柟娉曪細     print("鍙橀噺1", file_name, "鍙橀噺2", new_name)
print("鍙橀噺1", file_name, "鍙橀噺2", new_name) 

絎簩縐嶆柟娉曪細     print("鍙橀噺1錛?s 鍙橀噺2錛?s" % (file_name, new_name))

print("鍙橀噺1錛?s 鍙橀噺2錛?s" % (file_name, new_name)) 

絎笁縐嶆柟娉曪細.format()  

print('鍙橀噺1錛歿0} 鍙橀噺2錛歿1}'.format(file_name, new_name))

  1. print('鍙橀噺1錛歿0} 鍙橀噺2錛歿1}'.format(file_name, new_name))
  2. # 闇瑕佹敞鎰忕殑鏄紝python鏄粠0寮濮嬭鏁幫紝鎵浠ョ涓涓獅}閲岃浠?寮濮嬶紝渚濇1銆?…

Reference:
https://blog.csdn.net/zhangvalue/article/details/103841029


鏉板摜 2020-09-05 08:44 鍙戣〃璇勮
]]>
[zz] 3 涓浉瑙佹仺鏅氱殑 Google Colaboratory 濂囨妧http://www.shnenglu.com/guijie/archive/2019/02/13/216240.html鏉板摜鏉板摜Wed, 13 Feb 2019 15:56:00 GMThttp://www.shnenglu.com/guijie/archive/2019/02/13/216240.htmlhttp://www.shnenglu.com/guijie/comments/216240.htmlhttp://www.shnenglu.com/guijie/archive/2019/02/13/216240.html#Feedback0http://www.shnenglu.com/guijie/comments/commentRss/216240.htmlhttp://www.shnenglu.com/guijie/services/trackbacks/216240.html鍘熸枃鍑哄錛?/span>

https://www.kdnuggets.com/2018/02/essential-google-colaboratory-tips-tricks.html


璇曟兂涓涓嬶紝濡傛灉鏈変釜鍏嶈垂鐨勫湪綰夸簯绔鉤鍙幫紝鏃㈠彲浠ヤ笉鐢ㄥ畨瑁?TensorFlow 鐩存帴浣跨敤錛屽張鍙互瀹炵幇 GPU 鍔犻熻緇冿紝閭h鏄濂界殑涓浠朵簨鎯呫備綘娌″惉閿欙紝榪欑濂戒簨紜疄瀛樺湪錛佷粖澶╂垜灝遍噸紓呬粙緇嶄竴涓胺姝屾帹鍑虹殑鍏嶈垂鐨勪簯绔伐鍏鳳細Colaboratory銆?/span>


Colaboratory 鏄竴涓?Google 鐮旂┒欏圭洰錛屾棬鍦ㄥ府鍔╀紶鎾満鍣ㄥ涔犲煿璁拰鐮旂┒鎴愭灉銆?/span>瀹冩槸涓涓?Jupyter 絎旇鏈幆澧?/span>錛屼笉闇瑕佽繘琛屼換浣曡緗氨鍙互浣跨敤錛屽茍涓斿畬鍏ㄥ湪浜戠榪愯銆侰olaboratory 絎旇鏈瓨鍌ㄥ湪 Google 浜戠紜洏涓紝騫朵笖鍙互鍏變韓錛屽氨濡傚悓鎮ㄤ嬌鐢?Google 鏂囨。鎴栬〃鏍間竴鏍楓侰olaboratory 鍙厤璐逛嬌鐢ㄣ?/span>


涔熷氨鏄錛孋olaboratory 瀛樺偍鍦?Google 浜戠紜洏涓紝鎴戜滑鍙互鍦?Google 浜戠紜洏閲岀洿鎺ョ紪鍐?Jupyter Notebook錛屽湪綰夸嬌鐢ㄦ繁搴﹀涔犳鏋?TensorFlow 騫惰緇冩垜浠殑紲炵粡緗戠粶浜嗐傝秴鐐紒



榪欓噷鏈?3 涓護浜虹浉瑙佹仺鏅氱殑濂囨妧娣閥鏉ョ畝鍖栧畠鐨勪嬌鐢紝鍒嗗埆鏄細浣跨敤鍏嶈垂鐨?GPU銆佸畨瑁呭簱銆佷笂浼犲茍浣跨敤鏁版嵁鏂囦歡銆?/span>


涓嬮潰鍒嗗埆浠嬬粛錛?/span>


1. 浣跨敤鍏嶈垂鐨?GPU


鍦ㄦ墦寮鐨?Jupyter Notebook 涓紝閫夋嫨鑿滃崟鏍?#8220;浠g爜鎵ц紼嬪簭錛圧untime錛?/strong>”錛?#8220;鏇存敼榪愯綾誨瀷錛圕hange runtime type錛?/strong>”錛岃繖鏃跺皢鐪嬪埌浠ヤ笅寮瑰嚭紿楀彛錛?/span>

紜繚“紜歡鍔犻熷櫒錛圚ardware accelerator錛?#8221;璁劇疆涓?GPU錛堥粯璁や負 CPU錛夈?span style="color: #444444; font-family: "Microsoft Yahei", "Helvetica Neue", Helvetica, Arial, sans-serif; background-color: #ffffff;">璁劇疆瀹屾瘯鍚庣偣鍑諱繚瀛樸?/span>


鍊煎緱娉ㄦ剰鐨勬槸紜絎旇鏈浜?strong>宸茶繛鎺?/strong>鐨勭姸鎬侊細



媯鏌ユ槸鍚︾湡鐨勫紑鍚簡 GPU錛堝嵆褰撳墠榪炴帴鍒頒簡GPU瀹炰緥錛夛紝鍙互鐩存帴鍦?Jupyter Notebook 涓繍琛屼互涓嬪懡浠?/span>錛?/span>


import tensorflow as tf
device_name = tf.test.gpu_device_name()
if device_name != '/device:GPU:0':
 raise SystemError('GPU device not found')
print('Found GPU at: {}'.format(device_name))

 

鑻ヨ緭鍑轟互涓嬭鍙ワ紝鍒欒〃鏄庡凡緇忎嬌鐢ㄤ簡 GPU 瀹炰緥銆?/span>


Found GPU at: /device:GPU:0


浣嗘槸錛岀敱浜庡湪綰?GPU 璧勬簮鏈夐檺錛屾湁鏃跺欏彲鑳戒細鍑虹幇涓嬮潰鐨勯棶棰樻彁紺猴細



 

灝辮繖鏍鳳紝璋鋒瓕鍏佽浣犱竴嬈℃渶澶氭寔緇嬌鐢?12 灝忔椂鐨勫厤璐?GPU銆?/span>


2. 瀹夎搴?/span>


鐩墠錛屽湪 Google Colaboratory 涓畨瑁呯殑杞歡騫朵笉鏄寔涔呯殑錛屾剰鍛崇潃姣忔閲嶆柊榪炴帴瀹炰緥鏃墮兘闇瑕侀噸鏂板畨瑁呫備絾鏄紝Colab 宸茬粡榛樿瀹夎浜嗛渶瑕佹湁鐢ㄧ殑搴擄紝瀹夎鏂扮殑搴撲篃騫墮潪闅句簨錛屾柟娉曚篃鏈夊ソ鍑犵銆?/span>


浣嗛渶瑕佹敞鎰忕殑鏄紝瀹夎浠諱綍闇瑕佷粠婧愪唬鐮佹瀯寤虹殑杞歡鍙兘闇瑕佸緢闀跨殑鏃墮棿銆?/span>


Colab 鍚屾椂鏀寔 pip 鍜?apt 鍖呯鐞嗗櫒銆傛棤璁烘偍浣跨敤鐨勬槸鍝竴涓紝璁頒綇瑕佸湪鍛戒護鍓嶉潰鍔犱笂絎﹀彿 “!”銆?/span>


# Install Keras with pip
!pip install -q keras
import keras

>
>> Using TensorFlow backend.

#
Install GraphViz with apt
!apt-get install graphviz -y



3. 涓婁紶騫朵嬌鐢ㄦ暟鎹枃浠?/span>


鎴戜滑涓鑸兘闇瑕佸湪 Colab 絎旇鏈腑浣跨敤鏁版嵁錛屽鍚э紵浣犲彲浠ヤ嬌鐢?wget 涔嬬被鐨勫伐鍏蜂粠緗戠粶涓婅幏鍙栨暟鎹紝浣嗘槸濡傛灉浣犳湁涓浜涙湰鍦版枃浠訛紝鎯充笂浼犲埌浣犵殑璋鋒瓕紜洏涓殑 Colab 鐜閲屽茍浣跨敤瀹冧滑錛岃鎬庝箞鍋氬憿錛?/span>


寰堢畝鍗曪紝鍙渶 3 姝ュ嵆鍙疄鐜幫紒


棣栧厛浣跨敤浠ヤ笅鍛戒護璋冪敤絎旇鏈腑鐨勬枃浠墮夋嫨鍣細


from google.colab import files
uploaded = files.upload()


榪愯涔嬪悗錛屾垜浠氨浼氬彂鐜板崟鍏?cell 涓嬪嚭鐜頒簡“閫夋嫨鏂囦歡”鎸夐挳錛?/span>



榪欐牱灝卞彲浠ョ洿鎺ラ夋嫨浣犳兂涓婁紶鐨勬枃浠跺暒錛?/span>


閫夋嫨鏂囦歡鍚庯紝浣跨敤浠ヤ笅榪唬鏂規硶涓婁紶鏂囦歡浠ユ煡鎵懼叾閿悕錛屽懡浠ゅ涓嬶細


for fn in uploaded.keys():
 print('User uploaded file "{name}" with length {length} bytes'.format(name=fn, length=len(uploaded[fn])))


渚嬪寰呬笂浼犵殑鏄?iris.csv 鏂囦歡錛岃嫢榪愯娌℃湁闂鐨勮瘽錛屽簲璇ュ嚭鐜扮被浼間笅闈㈢殑鎻愮ず璇彞錛?/span>


User uploaded file "iris.csv" with length 3716 bytes


鏈鍚庯紝灝變嬌鐢ㄤ互涓嬪懡浠ゅ皢鏂囦歡鐨勫唴瀹瑰姞杞藉埌 Pandas 鐨?DataFrame 涓簡錛?/span>


import pandas as pd
import io
df = pd.read_csv(io.StringIO(uploaded['iris.csv'].decode('utf-8')))
print(df)


榪欑涓婁紶鏂囦歡鐨勬柟娉曟槸涓嶆槸寰堢畝鍗曞憿錛熷綋鐒訛紝涓婁紶鍜屼嬌鐢ㄦ暟鎹枃浠惰繕鏈夊叾瀹冪殑鏂規硶錛屼絾鏄垜鍙戠幇榪欎竴鏂規硶鏈綆鍗曟槑浜嗐?/span>


浠ヤ笂灝辨槸鍏充簬 Google Calaboratory 鐨?3 涓潪甯稿疄鐢ㄧ殑鎶宸э紝璧剁揣灝濊瘯涓涓嬪惂錛?/span>


鏈鍚庯紝鍙兘鏈夌殑璇昏呮湅鍙嬪 Google Calaboratory 涓嶅お浜嗚В鐨勶紝鍙互鏌ョ湅鎴戜箣鍓嶅啓鐨勪竴綃囨枃绔狅細濡備綍鍦ㄥ厤璐逛簯绔繍琛?Python 娣卞害瀛︿範妗嗘灦錛?/strong>閾炬帴濡備笅錛?/span>


https://redstonewill.com/1493/


涔熷彲浠ョ偣鍑?strong>闃呰鍘熸枃鏌ョ湅錛?/span>


Reference:
https://mp.weixin.qq.com/s/vLnBFPZNvIjs4R7d4_6M_g


鏉板摜 2019-02-13 23:56 鍙戣〃璇勮
]]>
[zz]Python涓笅鍒掔嚎鐨?縐嶅惈涔?/title><link>http://www.shnenglu.com/guijie/archive/2019/02/02/216230.html</link><dc:creator>鏉板摜</dc:creator><author>鏉板摜</author><pubDate>Fri, 01 Feb 2019 17:51:00 GMT</pubDate><guid>http://www.shnenglu.com/guijie/archive/2019/02/02/216230.html</guid><wfw:comment>http://www.shnenglu.com/guijie/comments/216230.html</wfw:comment><comments>http://www.shnenglu.com/guijie/archive/2019/02/02/216230.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/guijie/comments/commentRss/216230.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/guijie/services/trackbacks/216230.html</trackback:ping><description><![CDATA[<div><div style="overflow: hidden; width: 690px; margin: 0px auto; color: #1a1a1a; font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; font-size: medium; background-color: #ffffff;"><div ztext="" post-richtext"="" style="word-break: break-word; line-height: 1.6; margin-top: 20px;"><p style="margin: 0px 0px 1.4em;">鍒嗕韓涓綃囨枃绔狅細<a wrap="" external"="" target="_blank" rel="nofollow noreferrer" data-za-detail-view-id="1043" style="text-decoration-line: none; cursor: pointer; border-bottom: 1px solid #808080;">The Meaning of Underscores in Python</a>銆?/p><p style="margin: 1.4em 0px;">鏈枃浠嬬粛浜哖ython涓崟涓嬪垝綰垮拰鍙屼笅鍒掔嚎錛?dunder"錛夌殑鍚勭鍚箟鍜屽懡鍚嶇害瀹氾紝鍚嶇О淇グ錛坣ame mangling錛夌殑宸ヤ綔鍘熺悊錛屼互鍙婂畠濡備綍褰卞搷浣犺嚜宸辯殑Python綾匯?/p><p style="margin: 1.4em 0px;">鍗曚笅鍒掔嚎鍜屽弻涓嬪垝綰垮湪Python鍙橀噺鍜屾柟娉曞悕縐頒腑閮藉悇鏈夊叾鍚箟銆傛湁涓浜涘惈涔変粎浠呮槸渚濈収綰﹀畾錛岃瑙嗕綔鏄紼嬪簭鍛樼殑鎻愮ず - 鑰屾湁涓浜涘惈涔夋槸鐢盤ython瑙i噴鍣ㄤ弗鏍兼墽琛岀殑銆?/p><p style="margin: 1.4em 0px;">濡傛灉浣犳兂鐭ラ亾“Python鍙橀噺鍜屾柟娉曞悕縐頒腑鍗曚笅鍒掔嚎鍜屽弻涓嬪垝綰跨殑鍚箟鏄粈涔堬紵”錛屾垜浼氬敖鎴戞墍鑳藉湪榪欓噷涓轟綘瑙g瓟銆?/p><p style="margin: 1.4em 0px;">鍦ㄦ湰鏂囦腑錛屾垜灝嗚璁轟互涓嬩簲縐嶄笅鍒掔嚎妯″紡鍜屽懡鍚嶇害瀹氾紝浠ュ強瀹冧滑濡備綍褰卞搷Python紼嬪簭鐨勮涓猴細</p><ul style="padding: 0px; margin: 1.4em 0px; display: table;"><li style="list-style: none; display: table-row;">鍗曞墠瀵間笅鍒掔嚎錛歘var</li><li style="list-style: none; display: table-row;">鍗曟湯灝句笅鍒掔嚎錛歷ar_</li><li style="list-style: none; display: table-row;">鍙屽墠瀵間笅鍒掔嚎錛歘_var</li><li style="list-style: none; display: table-row;">鍙屽墠瀵煎拰鏈熬涓嬪垝綰匡細__var__</li><li style="list-style: none; display: table-row;">鍗曚笅鍒掔嚎錛歘</li></ul><p style="margin: 1.4em 0px;">鍦ㄦ枃绔犵粨灝懼錛屼綘鍙互鎵懼埌涓涓畝鐭殑“閫熸煡琛?#8221;錛屾葷粨浜嗕簲縐嶄笉鍚岀殑涓嬪垝綰垮懡鍚嶇害瀹氬強鍏跺惈涔夛紝浠ュ強涓涓畝鐭殑瑙嗛鏁欑▼錛屽彲璁╀綘浜茶韓浣撻獙瀹冧滑鐨勮涓恒?/p><p style="margin: 1.4em 0px;">璁╂垜浠┈涓婂紑濮嬶紒</p><h2>1. 鍗曞墠瀵間笅鍒掔嚎 _var</h2><p style="margin: 1.4em 0px;">褰撴秹鍙婂埌鍙橀噺鍜屾柟娉曞悕縐版椂錛屽崟涓笅鍒掔嚎鍓嶇紑鏈変竴涓害瀹氫織鎴愮殑鍚箟銆?瀹冩槸瀵圭▼搴忓憳鐨勪竴涓彁紺?- 鎰忓懗鐫Python紺懼尯涓鑷磋涓哄畠搴旇鏄粈涔堟剰鎬濓紝浣嗙▼搴忕殑琛屼負涓嶅彈褰卞搷銆?/p><p style="margin: 1.4em 0px;">涓嬪垝綰垮墠緙鐨勫惈涔夋槸鍛婄煡鍏朵粬紼嬪簭鍛橈細浠ュ崟涓笅鍒掔嚎寮澶寸殑鍙橀噺鎴栨柟娉曚粎渚涘唴閮ㄤ嬌鐢ㄣ?璇ョ害瀹氬湪PEP 8涓湁瀹氫箟銆?/p><p style="margin: 1.4em 0px;">榪欎笉鏄疨ython寮哄埗瑙勫畾鐨勩?Python涓嶅儚Java閭f牱鍦?#8220;縐佹湁”鍜?#8220;鍏叡”鍙橀噺涔嬮棿鏈夊緢寮虹殑鍖哄埆銆?榪欏氨鍍忔湁浜烘彁鍑轟簡涓涓皬灝忕殑涓嬪垝綰胯鍛婃爣蹇楋紝璇達細</p><blockquote style="margin: 1.4em 0px; padding-left: 1em; color: #646464; border-left-width: 3px; border-left-color: #d3d3d3;">“鍢匡紝榪欎笉鏄湡鐨勮鎴愪負綾葷殑鍏叡鎺ュ彛鐨勪竴閮ㄥ垎銆備笉鍘葷瀹冨氨濂姐?#8220;</blockquote><p style="margin: 1.4em 0px;">鐪嬬湅涓嬮潰鐨勪緥瀛愶細</p><div style="margin: 1em 0px;"><pre style="margin-top: 0px; margin-bottom: 0px; padding: calc(0.888889em); font-size: 0.9em; word-break: initial; overflow-wrap: initial; overflow: auto; background: #f6f6f6; border-radius: 4px;"><code style="margin: 0px; padding: 0px; border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Andale Mono", "lucida console", "Courier New", monospace; font-size: inherit; background-color: inherit;">class Test: def __init__(self): self.foo = 11 self._bar = 23 </code></pre></div><p style="margin: 1.4em 0px;">濡傛灉浣犲疄渚嬪寲姝ょ被錛屽茍灝濊瘯璁塊棶鍦╛_init__鏋勯犲嚱鏁頒腑瀹氫箟鐨刦oo鍜宊bar灞炴э紝浼氬彂鐢熶粈涔堟儏鍐碉紵 璁╂垜浠潵鐪嬬湅錛?/p><div style="margin: 1em 0px;"><pre style="margin-top: 0px; margin-bottom: 0px; padding: calc(0.888889em); font-size: 0.9em; word-break: initial; overflow-wrap: initial; overflow: auto; background: #f6f6f6; border-radius: 4px;"><code style="margin: 0px; padding: 0px; border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Andale Mono", "lucida console", "Courier New", monospace; font-size: inherit; background-color: inherit;">>>> t = Test() >>> t.foo 11 >>> t._bar 23 </code></pre></div><p style="margin: 1.4em 0px;">浣犱細鐪嬪埌_bar涓殑鍗曚釜涓嬪垝綰垮茍娌℃湁闃繪鎴戜滑“榪涘叆”綾誨茍璁塊棶璇ュ彉閲忕殑鍊箋?/p><p style="margin: 1.4em 0px;">榪欐槸鍥犱負Python涓殑鍗曚釜涓嬪垝綰垮墠緙浠呬粎鏄竴涓害瀹?- 鑷沖皯鐩稿浜庡彉閲忓拰鏂規硶鍚嶈岃█銆?/p><p style="margin: 1.4em 0px;">浣嗘槸錛屽墠瀵間笅鍒掔嚎鐨勭‘浼氬獎鍝嶄粠妯″潡涓鍏ュ悕縐扮殑鏂瑰紡銆?/p><p style="margin: 1.4em 0px;">鍋囪浣犲湪涓涓悕涓簃y_module鐨勬ā鍧椾腑鏈変互涓嬩唬鐮侊細</p><div style="margin: 1em 0px;"><pre style="margin-top: 0px; margin-bottom: 0px; padding: calc(0.888889em); font-size: 0.9em; word-break: initial; overflow-wrap: initial; overflow: auto; background: #f6f6f6; border-radius: 4px;"><code style="margin: 0px; padding: 0px; border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Andale Mono", "lucida console", "Courier New", monospace; font-size: inherit; background-color: inherit;"># This is my_module.py: def external_func(): return 23 def _internal_func(): return 42 </code></pre></div><p style="margin: 1.4em 0px;">鐜板湪錛屽鏋滀嬌鐢ㄩ氶厤絎︿粠妯″潡涓鍏ユ墍鏈夊悕縐幫紝鍒橮ython涓嶄細瀵煎叆甯︽湁鍓嶅涓嬪垝綰跨殑鍚嶇О錛堥櫎闈炴ā鍧楀畾涔変簡瑕嗙洊姝よ涓虹殑__all__鍒楄〃錛夛細</p><div style="margin: 1em 0px;"><pre style="margin-top: 0px; margin-bottom: 0px; padding: calc(0.888889em); font-size: 0.9em; word-break: initial; overflow-wrap: initial; overflow: auto; background: #f6f6f6; border-radius: 4px;"><code style="margin: 0px; padding: 0px; border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Andale Mono", "lucida console", "Courier New", monospace; font-size: inherit; background-color: inherit;">>>> from my_module import * >>> external_func() 23 >>> _internal_func() NameError: "name '_internal_func' is not defined" </code></pre></div><p style="margin: 1.4em 0px;">欏轟究璇翠竴涓嬶紝搴旇閬垮厤閫氶厤絎﹀鍏ワ紝鍥犱負瀹冧滑浣垮悕縐扮┖闂翠腑瀛樺湪鍝簺鍚嶇О涓嶆竻妤氥?涓轟簡娓呮璧瘋錛屽潥鎸佸父瑙勫鍏ユ洿濂姐?br /></p><p style="margin: 1.4em 0px;">涓庨氶厤絎﹀鍏ヤ笉鍚岋紝甯歌瀵煎叆涓嶅彈鍓嶅鍗曚釜涓嬪垝綰垮懡鍚嶇害瀹氱殑褰卞搷錛?/p><div style="margin: 1em 0px;"><pre style="margin-top: 0px; margin-bottom: 0px; padding: calc(0.888889em); font-size: 0.9em; word-break: initial; overflow-wrap: initial; overflow: auto; background: #f6f6f6; border-radius: 4px;"><code style="margin: 0px; padding: 0px; border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Andale Mono", "lucida console", "Courier New", monospace; font-size: inherit; background-color: inherit;">>>> import my_module >>> my_module.external_func() 23 >>> my_module._internal_func() 42 </code></pre></div><p style="margin: 1.4em 0px;">鎴戠煡閬撹繖涓鐐瑰彲鑳芥湁鐐逛護浜哄洶鎯戙?濡傛灉浣犻伒寰狿EP 8鎺ㄨ崘錛岄伩鍏嶉氶厤絎﹀鍏ワ紝閭d箞浣犵湡姝i渶瑕佽浣忕殑鍙湁榪欎釜錛?/p><blockquote style="margin: 1.4em 0px; padding-left: 1em; color: #646464; border-left-width: 3px; border-left-color: #d3d3d3;">鍗曚釜涓嬪垝綰挎槸涓涓狿ython鍛藉悕綰﹀畾錛岃〃紺鴻繖涓悕縐版槸渚涘唴閮ㄤ嬌鐢ㄧ殑銆?瀹冮氬父涓嶇敱Python瑙i噴鍣ㄥ己鍒舵墽琛岋紝浠呬粎浣滀負涓縐嶅紼嬪簭鍛樼殑鎻愮ず銆?/blockquote><h2>2. 鍗曟湯灝句笅鍒掔嚎 var_</h2><p style="margin: 1.4em 0px;">鏈夋椂鍊欙紝涓涓彉閲忕殑鏈鍚堥傜殑鍚嶇О宸茬粡琚竴涓叧閿瓧鎵鍗犵敤銆?鍥犳錛屽儚class鎴杁ef榪欐牱鐨勫悕縐頒笉鑳界敤浣淧ython涓殑鍙橀噺鍚嶇О銆?鍦ㄨ繖縐嶆儏鍐典笅錛屼綘鍙互闄勫姞涓涓笅鍒掔嚎鏉ヨВ鍐沖懡鍚嶅啿紿侊細</p><div style="margin: 1em 0px;"><pre style="margin-top: 0px; margin-bottom: 0px; padding: calc(0.888889em); font-size: 0.9em; word-break: initial; overflow-wrap: initial; overflow: auto; background: #f6f6f6; border-radius: 4px;"><code style="margin: 0px; padding: 0px; border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Andale Mono", "lucida console", "Courier New", monospace; font-size: inherit; background-color: inherit;">>>> def make_object(name, class): SyntaxError: "invalid syntax" >>> def make_object(name, class_): ... pass </code></pre></div><p style="margin: 1.4em 0px;">鎬諱箣錛屽崟涓湯灝句笅鍒掔嚎錛堝悗緙錛夋槸涓涓害瀹氾紝鐢ㄦ潵閬垮厤涓嶱ython鍏抽敭瀛椾駭鐢熷懡鍚嶅啿紿併?PEP 8瑙i噴浜嗚繖涓害瀹氥?/p><h2>3. 鍙屽墠瀵間笅鍒掔嚎 __var</h2><p style="margin: 1.4em 0px;">鍒扮洰鍓嶄負姝紝鎴戜滑鎵娑夊強鐨勬墍鏈夊懡鍚嶆ā寮忕殑鍚箟錛屾潵鑷簬宸茶揪鎴愬叡璇嗙殑綰﹀畾銆?鑰屽浜庝互鍙屼笅鍒掔嚎寮澶寸殑Python綾葷殑灞炴э紙鍖呮嫭鍙橀噺鍜屾柟娉曪級錛屾儏鍐靛氨鏈夌偣涓嶅悓浜嗐?/p><p style="margin: 1.4em 0px;">鍙屼笅鍒掔嚎鍓嶇紑浼氬鑷碢ython瑙i噴鍣ㄩ噸鍐欏睘鎬у悕縐幫紝浠ラ伩鍏嶅瓙綾諱腑鐨勫懡鍚嶅啿紿併?/p><p style="margin: 1.4em 0px;">榪欎篃鍙仛鍚嶇О淇グ錛坣ame mangling錛?- 瑙i噴鍣ㄦ洿鏀瑰彉閲忕殑鍚嶇О錛屼互渚垮湪綾昏鎵╁睍鐨勬椂鍊欎笉瀹規槗浜х敓鍐茬獊銆?/p><p style="margin: 1.4em 0px;">鎴戠煡閬撹繖鍚搗鏉ュ緢鎶借薄銆?鍥犳錛屾垜緇勫悎浜嗕竴涓皬灝忕殑浠g爜紺轟緥鏉ヤ簣浠ヨ鏄庯細</p><div style="margin: 1em 0px;"><pre style="margin-top: 0px; margin-bottom: 0px; padding: calc(0.888889em); font-size: 0.9em; word-break: initial; overflow-wrap: initial; overflow: auto; background: #f6f6f6; border-radius: 4px;"><code style="margin: 0px; padding: 0px; border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Andale Mono", "lucida console", "Courier New", monospace; font-size: inherit; background-color: inherit;">class Test: def __init__(self): self.foo = 11 self._bar = 23 self.__baz = 23 </code></pre></div><p style="margin: 1.4em 0px;">璁╂垜浠敤鍐呯疆鐨刣ir()鍑芥暟鏉ョ湅鐪嬭繖涓璞$殑灞炴э細</p><div style="margin: 1em 0px;"><pre style="margin-top: 0px; margin-bottom: 0px; padding: calc(0.888889em); font-size: 0.9em; word-break: initial; overflow-wrap: initial; overflow: auto; background: #f6f6f6; border-radius: 4px;"><code style="margin: 0px; padding: 0px; border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Andale Mono", "lucida console", "Courier New", monospace; font-size: inherit; background-color: inherit;">>>> t = Test() >>> dir(t) ['_Test__baz', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_bar', 'foo'] </code></pre></div><p style="margin: 1.4em 0px;">浠ヤ笂鏄繖涓璞″睘鎬х殑鍒楄〃銆?璁╂垜浠潵鐪嬬湅榪欎釜鍒楄〃錛屽茍瀵繪壘鎴戜滑鐨勫師濮嬪彉閲忓悕縐癴oo錛宊bar鍜宊_baz - 鎴戜繚璇佷綘浼氭敞鎰忓埌涓浜涙湁瓚g殑鍙樺寲銆?br /></p><ul style="padding: 0px; margin: 1.4em 0px; display: table;"><li style="list-style: none; display: table-row;">self.foo鍙橀噺鍦ㄥ睘鎬у垪琛ㄤ腑鏄劇ず涓烘湭淇敼涓篺oo銆?/li><li style="list-style: none; display: table-row;">self._bar鐨勮涓烘柟寮忕浉鍚?- 瀹冧互_bar鐨勫艦寮忔樉紺哄湪綾諱笂銆?灝卞儚鎴戜箣鍓嶈榪囩殑錛屽湪榪欑鎯呭喌涓嬶紝鍓嶅涓嬪垝綰夸粎浠呮槸涓涓害瀹氥?緇欑▼搴忓憳涓涓彁紺鴻屽凡銆?/li><li style="list-style: none; display: table-row;">鐒惰岋紝瀵逛簬self.__baz鑰岃█錛屾儏鍐電湅璧鋒潵鏈夌偣涓嶅悓銆?褰撲綘鍦ㄨ鍒楄〃涓悳绱_baz鏃訛紝浣犱細鐪嬩笉鍒版湁榪欎釜鍚嶅瓧鐨勫彉閲忋?/li></ul><p style="margin: 1.4em 0px;">__baz鍑轟粈涔堟儏鍐典簡錛?/p><p style="margin: 1.4em 0px;">濡傛灉浣犱粩緇嗚瀵燂紝浣犱細鐪嬪埌姝ゅ璞′笂鏈変竴涓悕涓篲Test__baz鐨勫睘鎬с?榪欏氨鏄疨ython瑙i噴鍣ㄦ墍鍋氱殑鍚嶇О淇グ銆?瀹冭繖鏍峰仛鏄負浜嗛槻姝㈠彉閲忓湪瀛愮被涓閲嶅啓銆?/p><p style="margin: 1.4em 0px;">璁╂垜浠垱寤哄彟涓涓墿灞昑est綾葷殑綾伙紝騫跺皾璇曢噸鍐欐瀯閫犲嚱鏁頒腑娣誨姞鐨勭幇鏈夊睘鎬э細</p><div style="margin: 1em 0px;"><pre style="margin-top: 0px; margin-bottom: 0px; padding: calc(0.888889em); font-size: 0.9em; word-break: initial; overflow-wrap: initial; overflow: auto; background: #f6f6f6; border-radius: 4px;"><code style="margin: 0px; padding: 0px; border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Andale Mono", "lucida console", "Courier New", monospace; font-size: inherit; background-color: inherit;">class ExtendedTest(Test): def __init__(self): super().__init__() self.foo = 'overridden' self._bar = 'overridden' self.__baz = 'overridden' </code></pre></div><p style="margin: 1.4em 0px;">鐜板湪錛屼綘璁や負foo錛宊bar鍜宊_baz鐨勫間細鍑虹幇鍦ㄨ繖涓狤xtendedTest綾葷殑瀹炰緥涓婂悧錛?鎴戜滑鏉ョ湅涓鐪嬶細</p><div style="margin: 1em 0px;"><pre style="margin-top: 0px; margin-bottom: 0px; padding: calc(0.888889em); font-size: 0.9em; word-break: initial; overflow-wrap: initial; overflow: auto; background: #f6f6f6; border-radius: 4px;"><code style="margin: 0px; padding: 0px; border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Andale Mono", "lucida console", "Courier New", monospace; font-size: inherit; background-color: inherit;">>>> t2 = ExtendedTest() >>> t2.foo 'overridden' >>> t2._bar 'overridden' >>> t2.__baz AttributeError: "'ExtendedTest' object has no attribute '__baz'" </code></pre></div><p style="margin: 1.4em 0px;">絳変竴涓嬶紝褰撴垜浠皾璇曟煡鐪媡2 .__ baz鐨勫兼椂錛屼負浠涔堟垜浠細寰楀埌AttributeError錛?鍚嶇О淇グ琚啀嬈¤Е鍙戜簡錛?浜嬪疄璇佹槑錛岃繖涓璞$敋鑷蟲病鏈塤_baz灞炴э細</p><div style="margin: 1em 0px;"><pre style="margin-top: 0px; margin-bottom: 0px; padding: calc(0.888889em); font-size: 0.9em; word-break: initial; overflow-wrap: initial; overflow: auto; background: #f6f6f6; border-radius: 4px;"><code style="margin: 0px; padding: 0px; border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Andale Mono", "lucida console", "Courier New", monospace; font-size: inherit; background-color: inherit;">>>> dir(t2) ['_ExtendedTest__baz', '_Test__baz', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_bar', 'foo', 'get_vars'] </code></pre></div><p style="margin: 1.4em 0px;">姝e浣犲彲浠ョ湅鍒癬_baz鍙樻垚_ExtendedTest__baz浠ラ槻姝㈡剰澶栦慨鏀癸細</p><div style="margin: 1em 0px;"><pre style="margin-top: 0px; margin-bottom: 0px; padding: calc(0.888889em); font-size: 0.9em; word-break: initial; overflow-wrap: initial; overflow: auto; background: #f6f6f6; border-radius: 4px;"><code style="margin: 0px; padding: 0px; border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Andale Mono", "lucida console", "Courier New", monospace; font-size: inherit; background-color: inherit;">>>> t2._ExtendedTest__baz 'overridden' </code></pre></div><p style="margin: 1.4em 0px;">浣嗗師鏉ョ殑_Test__baz榪樺湪錛?/p><div style="margin: 1em 0px;"><pre style="margin-top: 0px; margin-bottom: 0px; padding: calc(0.888889em); font-size: 0.9em; word-break: initial; overflow-wrap: initial; overflow: auto; background: #f6f6f6; border-radius: 4px;"><code style="margin: 0px; padding: 0px; border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Andale Mono", "lucida console", "Courier New", monospace; font-size: inherit; background-color: inherit;">>>> t2._Test__baz 42 </code></pre></div><p style="margin: 1.4em 0px;">鍙屼笅鍒掔嚎鍚嶇О淇グ瀵圭▼搴忓憳鏄畬鍏ㄩ忔槑鐨勩?涓嬮潰鐨勪緥瀛愯瘉瀹炰簡榪欎竴鐐癸細</p><div style="margin: 1em 0px;"><pre style="margin-top: 0px; margin-bottom: 0px; padding: calc(0.888889em); font-size: 0.9em; word-break: initial; overflow-wrap: initial; overflow: auto; background: #f6f6f6; border-radius: 4px;"><code style="margin: 0px; padding: 0px; border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Andale Mono", "lucida console", "Courier New", monospace; font-size: inherit; background-color: inherit;">class ManglingTest: def __init__(self): self.__mangled = 'hello' def get_mangled(self): return self.__mangled >>> ManglingTest().get_mangled() 'hello' >>> ManglingTest().__mangled AttributeError: "'ManglingTest' object has no attribute '__mangled'" </code></pre></div><p style="margin: 1.4em 0px;">鍚嶇О淇グ鏄惁涔熼傜敤浜庢柟娉曞悕縐幫紵 鏄殑錛屼篃閫傜敤銆傚悕縐頒慨楗頒細褰卞搷鍦ㄤ竴涓被鐨勪笂涓嬫枃涓紝浠ヤ袱涓笅鍒掔嚎瀛楃錛?dunders"錛夊紑澶寸殑<span style="font-weight: 600;">鎵鏈?/span>鍚嶇О錛?/p><div style="margin: 1em 0px;"><pre style="margin-top: 0px; margin-bottom: 0px; padding: calc(0.888889em); font-size: 0.9em; word-break: initial; overflow-wrap: initial; overflow: auto; background: #f6f6f6; border-radius: 4px;"><code style="margin: 0px; padding: 0px; border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Andale Mono", "lucida console", "Courier New", monospace; font-size: inherit; background-color: inherit;">class MangledMethod: def __method(self): return 42 def call_it(self): return self.__method() >>> MangledMethod().__method() AttributeError: "'MangledMethod' object has no attribute '__method'" >>> MangledMethod().call_it() 42 </code></pre></div><p style="margin: 1.4em 0px;">榪欐槸鍙︿竴涓篃璁鎬護浜烘儕璁剁殑榪愮敤鍚嶇О淇グ鐨勪緥瀛愶細</p><div style="margin: 1em 0px;"><pre style="margin-top: 0px; margin-bottom: 0px; padding: calc(0.888889em); font-size: 0.9em; word-break: initial; overflow-wrap: initial; overflow: auto; background: #f6f6f6; border-radius: 4px;"><code style="margin: 0px; padding: 0px; border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Andale Mono", "lucida console", "Courier New", monospace; font-size: inherit; background-color: inherit;">_MangledGlobal__mangled = 23 class MangledGlobal: def test(self): return __mangled >>> MangledGlobal().test() 23 </code></pre></div><p style="margin: 1.4em 0px;">鍦ㄨ繖涓緥瀛愪腑錛屾垜澹版槑浜嗕竴涓悕涓篲MangledGlobal__mangled鐨勫叏灞鍙橀噺銆傜劧鍚庢垜鍦ㄥ悕涓篗angledGlobal鐨勭被鐨勪笂涓嬫枃涓闂彉閲忋傜敱浜庡悕縐頒慨楗幫紝鎴戣兘澶熷湪綾葷殑test()鏂規硶鍐咃紝浠_mangled鏉ュ紩鐢╛MangledGlobal__mangled鍏ㄥ眬鍙橀噺銆?br /><br />Python瑙i噴鍣ㄨ嚜鍔ㄥ皢鍚嶇О__mangled鎵╁睍涓篲MangledGlobal__mangled錛屽洜涓哄畠浠ヤ袱涓笅鍒掔嚎瀛楃寮澶淬傝繖琛ㄦ槑鍚嶇О淇グ涓嶆槸涓撻棬涓庣被灞炴у叧鑱旂殑銆傚畠閫傜敤浜庡湪綾諱笂涓嬫枃涓嬌鐢ㄧ殑涓や釜涓嬪垝綰垮瓧絎﹀紑澶寸殑浠諱綍鍚嶇О銆?br /><br />鏈夊緢澶氳鍚告敹鐨勫唴瀹瑰惂銆?br /><br />鑰佸疄璇達紝榪欎簺渚嬪瓙鍜岃В閲婁笉鏄粠鎴戣剳瀛愰噷韞﹀嚭鏉ョ殑銆傛垜浣滀簡涓浜涚爺絀跺拰鍔犲伐鎵嶅紕鍑烘潵銆傛垜涓鐩翠嬌鐢≒ython錛屾湁寰堝騫翠簡錛屼絾鏄儚榪欐牱鐨勮鍒欏拰鐗規畩鎯呭喌騫朵笉鎬繪槸嫻幇鍦ㄨ剳嫻烽噷銆?br /><br />鏈夋椂鍊欑▼搴忓憳鏈閲嶈鐨勬妧鑳芥槸“妯″紡璇嗗埆”錛岃屼笖鐭ラ亾鍦ㄥ摢閲屾煡闃呬俊鎭傚鏋滄偍鍦ㄨ繖涓鐐逛笂鎰熷埌鏈夌偣涓嶇煡鎵鎺紝璇蜂笉瑕佹媴蹇冦傛參鎱㈡潵錛岃瘯璇曡繖綃囨枃绔犱腑鐨勪竴浜涗緥瀛愩?br /><br />璁╄繖浜涙蹇靛畬鍏ㄦ矇嫻鎬笅鏉ワ紝浠ヤ究浣犺兘澶熺悊瑙e悕縐頒慨楗扮殑鎬諱綋鎬濊礬錛屼互鍙婃垜鍚戞偍灞曠ず鐨勪竴浜涘叾浠栫殑琛屼負銆傚鏋滄湁涓澶╀綘鍜屽畠浠笉鏈熻岄亣錛屼綘浼氱煡閬撳湪鏂囨。涓寜浠涔堟潵鏌ャ?/p><h2>4. 鍙屽墠瀵煎拰鍙屾湯灝句笅鍒掔嚎 _var_</h2><p style="margin: 1.4em 0px;">涔熻浠や漢鎯婅鐨勬槸錛屽鏋滀竴涓悕瀛楀悓鏃朵互鍙屼笅鍒掔嚎寮濮嬪拰緇撴潫錛屽垯涓嶄細搴旂敤鍚嶇О淇グ銆?鐢卞弻涓嬪垝綰垮墠緙鍜屽悗緙鍖呭洿鐨勫彉閲忎笉浼氳Python瑙i噴鍣ㄤ慨鏀癸細</p><div style="margin: 1em 0px;"><pre style="margin-top: 0px; margin-bottom: 0px; padding: calc(0.888889em); font-size: 0.9em; word-break: initial; overflow-wrap: initial; overflow: auto; background: #f6f6f6; border-radius: 4px;"><code style="margin: 0px; padding: 0px; border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Andale Mono", "lucida console", "Courier New", monospace; font-size: inherit; background-color: inherit;">class PrefixPostfixTest: def __init__(self): self.__bam__ = 42 >>> PrefixPostfixTest().__bam__ 42 </code></pre></div><p style="margin: 1.4em 0px;">浣嗘槸錛孭ython淇濈暀浜嗘湁鍙屽墠瀵煎拰鍙屾湯灝句笅鍒掔嚎鐨勫悕縐幫紝鐢ㄤ簬鐗規畩鐢ㄩ斻?榪欐牱鐨勪緥瀛愭湁錛宊_init__瀵硅薄鏋勯犲嚱鏁幫紝鎴朹_call__ --- 瀹冧嬌寰椾竴涓璞″彲浠ヨ璋冪敤銆?/p><p style="margin: 1.4em 0px;">榪欎簺dunder鏂規硶閫氬父琚О涓虹濂囨柟娉?- 浣哖ython紺懼尯涓殑璁稿浜猴紙鍖呮嫭鎴戣嚜宸憋級閮戒笉鍠滄榪欑鏂規硶銆?/p><p style="margin: 1.4em 0px;">鏈濂介伩鍏嶅湪鑷繁鐨勭▼搴忎腑浣跨敤浠ュ弻涓嬪垝綰匡紙“dunders”錛夊紑澶村拰緇撳熬鐨勫悕縐幫紝浠ラ伩鍏嶄笌灝嗘潵Python璇█鐨勫彉鍖栦駭鐢熷啿紿併?/p><h2>5.鍗曚笅鍒掔嚎 _</h2><p style="margin: 1.4em 0px;">鎸夌収涔犳儻錛屾湁鏃跺欏崟涓嫭绔嬩笅鍒掔嚎鏄敤浣滀竴涓悕瀛楋紝鏉ヨ〃紺烘煇涓彉閲忔槸涓存椂鐨勬垨鏃犲叧绱ц鐨勩?br /></p><p style="margin: 1.4em 0px;">渚嬪錛屽湪涓嬮潰鐨勫驚鐜腑錛屾垜浠笉闇瑕佽闂鍦ㄨ繍琛岀殑绱㈠紩錛屾垜浠彲浠ヤ嬌鐢?#8220;_”鏉ヨ〃紺哄畠鍙槸涓涓復鏃跺鹼細</p><div style="margin: 1em 0px;"><pre style="margin-top: 0px; margin-bottom: 0px; padding: calc(0.888889em); font-size: 0.9em; word-break: initial; overflow-wrap: initial; overflow: auto; background: #f6f6f6; border-radius: 4px;"><code style="margin: 0px; padding: 0px; border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Andale Mono", "lucida console", "Courier New", monospace; font-size: inherit; background-color: inherit;">>>> for _ in range(32): ... print('Hello, World.') </code></pre></div><p style="margin: 1.4em 0px;">浣犱篃鍙互鍦ㄦ媶鍒?unpacking)琛ㄨ揪寮忎腑灝嗗崟涓笅鍒掔嚎鐢ㄤ綔“涓嶅叧蹇冪殑”鍙橀噺錛屼互蹇界暐鐗瑰畾鐨勫箋?鍚屾牱錛岃繖涓惈涔夊彧鏄?#8220;渚濈収綰﹀畾”錛屽茍涓嶄細鍦≒ython瑙i噴鍣ㄤ腑瑙﹀彂鐗規畩鐨勮涓恒?鍗曚釜涓嬪垝綰夸粎浠呮槸涓涓湁鏁堢殑鍙橀噺鍚嶇О錛屼細鏈夎繖涓敤閫旇屽凡銆?/p><p style="margin: 1.4em 0px;">鍦ㄤ笅闈㈢殑浠g爜紺轟緥涓紝鎴戝皢姹借濺鍏冪粍鎷嗗垎涓哄崟鐙殑鍙橀噺錛屼絾鎴戝彧瀵歸鑹插拰閲岀▼鍊兼劅鍏磋叮銆?浣嗘槸錛屼負浜嗕嬌鎷嗗垎琛ㄨ揪寮忔垚鍔熻繍琛岋紝鎴戦渶瑕佸皢鍖呭惈鍦ㄥ厓緇勪腑鐨勬墍鏈夊煎垎閰嶇粰鍙橀噺銆?鍦ㄨ繖縐嶆儏鍐典笅錛?#8220;_”浣滀負鍗犱綅絎﹀彉閲忓彲浠ユ淳涓婄敤鍦猴細</p><div style="margin: 1em 0px;"><pre style="margin-top: 0px; margin-bottom: 0px; padding: calc(0.888889em); font-size: 0.9em; word-break: initial; overflow-wrap: initial; overflow: auto; background: #f6f6f6; border-radius: 4px;"><code style="margin: 0px; padding: 0px; border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Andale Mono", "lucida console", "Courier New", monospace; font-size: inherit; background-color: inherit;">>>> car = ('red', 'auto', 12, 3812.4) >>> color, _, _, mileage = car >>> color 'red' >>> mileage 3812.4 >>> _ 12 </code></pre></div><p style="margin: 1.4em 0px;">闄や簡鐢ㄤ綔涓存椂鍙橀噺涔嬪錛?#8220;_”鏄ぇ澶氭暟Python REPL涓殑涓涓壒孌婂彉閲忥紝瀹冭〃紺虹敱瑙i噴鍣ㄨ瘎浼扮殑鏈榪戜竴涓〃杈懼紡鐨勭粨鏋溿?/p><p style="margin: 1.4em 0px;">榪欐牱灝卞緢鏂逛究浜嗭紝姣斿浣犲彲浠ュ湪涓涓В閲婂櫒浼氳瘽涓闂厛鍓嶈綆楃殑緇撴灉錛屾垨鑰咃紝浣犳槸鍦ㄥ姩鎬佹瀯寤哄涓璞″茍涓庡畠浠氦浜掞紝鏃犻渶浜嬪厛緇欒繖浜涘璞″垎閰嶅悕瀛楋細</p><div style="margin: 1em 0px;"><pre style="margin-top: 0px; margin-bottom: 0px; padding: calc(0.888889em); font-size: 0.9em; word-break: initial; overflow-wrap: initial; overflow: auto; background: #f6f6f6; border-radius: 4px;"><code style="margin: 0px; padding: 0px; border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Andale Mono", "lucida console", "Courier New", monospace; font-size: inherit; background-color: inherit;">>>> 20 + 3 23 >>> _ 23 >>> print(_) 23 >>> list() [] >>> _.append(1) >>> _.append(2) >>> _.append(3) >>> _ [1, 2, 3] </code></pre></div><h2>Python涓嬪垝綰垮懡鍚嶆ā寮?- 灝忕粨</h2><p style="margin: 1.4em 0px;">浠ヤ笅鏄竴涓畝鐭殑灝忕粨錛屽嵆“閫熸煡琛?#8221;錛岀綏鍒椾簡鎴戝湪鏈枃涓皥鍒扮殑浜旂Python涓嬪垝綰挎ā寮忕殑鍚箟錛?/p><figure style="margin: 1.4em 0px;"><img src="https://pic3.zhimg.com/80/v2-cbc5c6037101c7d33cf0acd9f00a8cfa_hd.jpg" data-caption="" data-size="normal" data-rawwidth="732" data-rawheight="314" zh-lightbox-thumb="" lazy"="" width="732" data-original="https://pic3.zhimg.com/v2-cbc5c6037101c7d33cf0acd9f00a8cfa_r.jpg" data-actualsrc="https://pic3.zhimg.com/v2-cbc5c6037101c7d33cf0acd9f00a8cfa_b.jpg" style="display: block; max-width: 100%; margin: 0px auto; cursor: zoom-in;" alt="" /></figure><hr style="margin: 4em auto; width: 240px; max-width: 100%; border-right: none; border-bottom: none; border-left: none; border-image: initial; border-top-style: solid; border-top-color: #d3d3d3;" /><p style="margin: 1.4em 0px;">浣犳兂鏇存繁鍏ヤ簡瑙e涔燩ython鐭ヨ瘑浣撶郴錛屼綘鍙互鐪嬩竴涓嬫垜浠姳璐逛簡涓涓鏈堟暣鐞嗕簡涓婄櫨灝忔椂鐨勫嚑鐧句釜鐭ヨ瘑鐐逛綋緋誨唴瀹癸細</p><p style="margin: 1.4em 0px 0px;"><a wrap="" external"="" target="_blank" rel="nofollow noreferrer" data-za-detail-view-id="1043" style="text-decoration-line: none; cursor: pointer; border-bottom: 1px solid #808080;">銆愯秴鍏ㄦ暣鐞嗐戙奝ython鑷姩鍖栧叏鑳藉紑鍙戜粠鍏ラ棬鍒扮簿閫氥媝ython鍩虹鏁欑▼絎旇</a></p></div></div><div style="margin: 0px auto; color: #8590a6; padding-top: 16px; padding-bottom: 16px; overflow: hidden; width: 690px; font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; background-color: #ffffff;">鍙戝竷浜?2018-04-26</div><div style="overflow: hidden; width: 690px; margin: 0px auto; display: flex; color: #1a1a1a; font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; font-size: medium; background-color: #ffffff;"><div post-topics"="" style="display: flex; flex-flow: row wrap; align-items: center; margin-bottom: -10px; padding-top: 16px; padding-bottom: 16px;"><div topic"="" data-za-detail-view-path-module="TopicItem" data-za-extra-module="{"card":{"content":{"type":"Topic","token":"19552832"}}}" style="position: relative; display: inline-block; height: 33px; padding-right: 12px; padding-left: 12px; font-size: 13px; line-height: 33px; color: #0084ff; vertical-align: top; border-radius: 100px; background: rgba(0, 132, 255, 0.1); margin-right: 5px; overflow: hidden; margin-bottom: 10px;"><a target="_blank" style="text-decoration-line: none;"><div style="position: relative; display: inline-block;"><div class="hvzpftn" id="Popover3-toggle" aria-haspopup="true" aria-expanded="false" aria-owns="Popover3-content">Python</div></div></a></div></div></div><br />Reference:<br />https://zhuanlan.zhihu.com/p/36173202</div><img src ="http://www.shnenglu.com/guijie/aggbug/216230.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/guijie/" target="_blank">鏉板摜</a> 2019-02-02 01:51 <a href="http://www.shnenglu.com/guijie/archive/2019/02/02/216230.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>[zz]Python3涓璵ap鍑芥暟鐨勯棶棰?/title><link>http://www.shnenglu.com/guijie/archive/2019/01/03/216164.html</link><dc:creator>鏉板摜</dc:creator><author>鏉板摜</author><pubDate>Thu, 03 Jan 2019 04:01:00 GMT</pubDate><guid>http://www.shnenglu.com/guijie/archive/2019/01/03/216164.html</guid><wfw:comment>http://www.shnenglu.com/guijie/comments/216164.html</wfw:comment><comments>http://www.shnenglu.com/guijie/archive/2019/01/03/216164.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/guijie/comments/commentRss/216164.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/guijie/services/trackbacks/216164.html</trackback:ping><description><![CDATA[<div>Python3涓璵ap鍑芥暟</div><div>鍦≒ython2涓璵ap鍑芥暟浼氳繑鍥炰竴涓猯ist鍒楄〃錛屽浠g爜錛?/div><div>>>> def f(x, y): return (x, y)</div><div>>>> l1 = [ 0, 1, 2, 3, 4, 5, 6 ]</div><div>>>> l2 = [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ]</div><div></div><div>榪斿洖緇撴灉濡備笅錛?/div><div>>>> map(f, l1, l2)</div><div>[(0, 'Sun'), (1, 'Mon'), (2, 'Tue'), (3, 'Wed'), (4, 'Thu'), (5, 'Fri'), (6, 'Sat')]</div><div></div><div>浣嗘槸錛屽湪Python3涓繑鍥炵粨鏋滃涓嬶細</div><div>>>> map(f1, l1, l2)</div><div><map object at 0x00000000021DA860></div><div></div><div>濡傛灉鎯寵寰楀埌Python2鐨勯偅縐嶇粨鏋滐紝鍗寵繑鍥瀕ist鍒楄〃錛岄偅涔堝繀欏葷敤list浣滅敤浜巑ap錛屽涓嬶細</div><div>>>> list(map(f1, l1, l2))</div><div>[(0, 'Sun'), (1, 'Mon'), (2, 'Tue'), (3, 'Wed'), (4, 'Thu'), (5, 'Fri'), (6, 'Sat')]<br /><br />reference:<br /><div>https://blog.csdn.net/u010376788/article/details/48230257</div></div><img src ="http://www.shnenglu.com/guijie/aggbug/216164.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/guijie/" target="_blank">鏉板摜</a> 2019-01-03 12:01 <a href="http://www.shnenglu.com/guijie/archive/2019/01/03/216164.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>[zz]python姹傛暟瀛椾綅鏁扮殑鏂規硶http://www.shnenglu.com/guijie/archive/2018/12/29/216152.html鏉板摜鏉板摜Sat, 29 Dec 2018 06:00:00 GMThttp://www.shnenglu.com/guijie/archive/2018/12/29/216152.htmlhttp://www.shnenglu.com/guijie/comments/216152.htmlhttp://www.shnenglu.com/guijie/archive/2018/12/29/216152.html#Feedback0http://www.shnenglu.com/guijie/comments/commentRss/216152.htmlhttp://www.shnenglu.com/guijie/services/trackbacks/216152.html絎竴縐嶏細
鍒╃敤str()鍑芥暟灝嗘暟瀛楄漿鍖栨垚瀛楃涓詫紝鍐嶅埄鐢╨en()鍑芥暟鍒ゆ柇浣嶉暱銆?/p>
 1 a=Int(raw_input("the number you want type in:")   
2
b=len(str(a))
3
print b

絎簩縐嶏細
鍒╃敤闄?0鍙栧晢錛岄氳繃寰幆嬈℃暟鍒ゆ柇浣嶆暟銆?/p>

c=0
a=int(raw_input("the number you want type in:"))
while a!=0:
      a=a/10
      c +=1
print c


Reference:

https://www.cnblogs.com/54Leo/p/6133270.html


鏉板摜 2018-12-29 14:00 鍙戣〃璇勮
]]>
colabhttp://www.shnenglu.com/guijie/archive/2018/12/21/216130.html鏉板摜鏉板摜Fri, 21 Dec 2018 01:07:00 GMThttp://www.shnenglu.com/guijie/archive/2018/12/21/216130.htmlhttp://www.shnenglu.com/guijie/comments/216130.htmlhttp://www.shnenglu.com/guijie/archive/2018/12/21/216130.html#Feedback0http://www.shnenglu.com/guijie/comments/commentRss/216130.htmlhttp://www.shnenglu.com/guijie/services/trackbacks/216130.html
How to create a folder in colab? 璋鋒瓕鎼滅儲: colab new folder鎵懼埌榪欎釜閾炬帴: https://medium.com/lean-in-women-in-tech-india/google-colab-the-beginners-guide-5ad3b417dfa
Create a Colab Notebook
Open Google Colab.
Click on ‘New Notebook’ and select Python 2 notebook or Python 3 notebook.
OR
Open Google Drive.
Create a new folder for the project.
Click on ‘New’ > ‘More’ > ‘Colaboratory’.
Google Drive -> 鎴戠殑浜戠紜洏 -> 鏂板緩鏂囦歡澶? Click on ‘New’ > ‘More’ > ‘Colaboratory’,榪欎釜鎬庝箞鎿嶄綔? 渚嬪閫変腑"02_backprop.ipynb", 鎵撳紑鏂瑰紡, 鍏寵仈鏇村搴旂敤, 閫夋嫨colab. 榪欐牱鍦╣oogle drive閲屽氨鍙互閫変腑"02_backprop.ipynb", 鎵撳紑鏂瑰紡, ‘Colaboratory’鍗沖彲.浣嗙洿鎺ユ墦寮Colab, Google drive閲岄潰鏄病鏈?02_backprop.ipynb", Recent鏈夈傛殏涓嶆姌鑵捐繖涓棶棰? Zhengxia璇碿olab搴旇浼氬垹,鍚﹀垯澶у閮芥妸瀹冨綋緗戠洏浣跨敤

02_backprop.ipynb, 鏈寮濮婩orward propagation涓婇潰, device鏀逛負GPU (device = torch.device('cuda') # Uncomment this to run on GPU),娌℃硶榪愯鍘熷洜? zhengxia says: Edit -> Notepad settings -> select GPU.濡傛灉涓涓柊鐢佃剳錛屼綘鑲畾瑕佽嚜宸遍厤緗笅cuda鍜宑udnn錛岃胺姝岃儲澶ф皵綺楋紝鐩稿綋榪欎簺閮藉府浣犲仛濂戒簡銆?/div>


鏉板摜 2018-12-21 09:07 鍙戣〃璇勮
]]>[zz] matplotlib.pyplot 涓樉紺哄浘鍍忕殑涓ょ妯″紡錛堜氦浜掑拰闃誨錛夊強鍏跺湪Python鐢誨浘涓殑搴旂敤http://www.shnenglu.com/guijie/archive/2018/12/17/216124.html鏉板摜鏉板摜Sun, 16 Dec 2018 22:10:00 GMThttp://www.shnenglu.com/guijie/archive/2018/12/17/216124.htmlhttp://www.shnenglu.com/guijie/comments/216124.htmlhttp://www.shnenglu.com/guijie/archive/2018/12/17/216124.html#Feedback0http://www.shnenglu.com/guijie/comments/commentRss/216124.htmlhttp://www.shnenglu.com/guijie/services/trackbacks/216124.html浠嬬粛

鍦ㄤ嬌鐢╩atplotlib鐨勮繃紼嬩腑錛屽彂鐜頒笉鑳藉儚matlab涓鏍峰悓鏃跺紑鍑犱釜紿楀彛榪涜姣旇緝錛屼簬鏄煡璇㈠緱鐭ヤ簡浜や簰妯″紡錛屼絾鏄斁鍦ㄨ剼鏈噷榪愯鐨勯傚悎鍗存繪槸涓闂岃繃錛屽浘鍍忓茍涓嶅仠鐣欙紝閬備粩緇嗛槄璇誨拰鐞嗚В浜嗕竴涓嬫枃妗o紝璁頒笅瑙e喅鍔炴硶錛岄棶棰樻瘮杈冪畝鍗曪紝浠呬緵鑿滈笩鍙傝冦?/p>

python鍙鍖栧簱matplotlib鏈変袱縐嶆樉紺烘ā寮忥細

  1. 闃誨錛坆lock錛夋ā寮?/li>
  2. 浜や簰錛坕nteractive錛夋ā寮?/li>

鍦≒ython Consol鍛戒護琛屼腑榪愯鑴氭湰錛岄粯璁ゆ槸闃誨妯″紡銆傝屽湪python IDE涓繍琛岃剼鏈紝matplotlib榛樿鏄氦浜掓ā寮忋傦紙浣跨敤python鍛戒護琛岃繍琛岃剼鏈笉鑳藉悓鏃舵樉紺轟笉鍚屽浘鍍忥級

鍏朵腑鐨勫尯鍒槸:

鍦ㄤ氦浜掓ā寮忎笅錛?/p>

  • plt.plot(x)鎴杙lt.imshow(x)鏄洿鎺ュ嚭鍥懼儚錛屼笉闇瑕乸lt.show()
  • 濡傛灉鍦ㄨ剼鏈腑浣跨敤ion()鍛戒護寮鍚簡浜や簰妯″紡錛屾病鏈変嬌鐢╥off()鍏抽棴鐨勮瘽錛屽垯鍥懼儚浼氫竴闂岃繃錛屽茍涓嶄細甯哥暀銆傝鎯抽槻姝㈣繖縐嶆儏鍐碉紝闇瑕佸湪plt.show()涔嬪墠鍔犱笂ioff()鍛戒護鎴栬呬嬌鐢?span style="box-sizing: border-box; outline: 0px; font-weight: 700; overflow-wrap: break-word;">plt.pause(seconds)寤墮暱鏄劇ず銆?/li>

鍦ㄩ樆濉炴ā寮忎笅錛?/p>

  • 鎵撳紑涓涓獥鍙d互鍚庡繀欏誨叧鎺夋墠鑳芥墦寮涓嬩竴涓柊鐨勭獥鍙c傝繖縐嶆儏鍐典笅錛岄粯璁ゆ槸涓嶈兘鍍廙atlab涓鏍峰悓鏃跺紑寰堝紿楀彛榪涜瀵規瘮鐨勩?/li>
  • plt.plot(x)鎴杙lt.imshow(x)鏄洿鎺ュ嚭鍥懼儚錛岄渶瑕乸lt.show()鍚庢墠鑳芥樉紺哄浘鍍?/li>

紺轟緥

涓嬮潰榪欎釜渚嬪瓙璁茬殑鏄浣曞儚matlab涓鏍峰悓鏃舵墦寮澶氫釜紿楀彛鏄劇ず鍥劇墖鎴栫嚎鏉¤繘琛屾瘮杈冿紝鍚屾椂涔熸槸鍦ㄨ剼鏈腑寮鍚氦浜掓ā寮忓悗鍥懼儚涓闂岃繃鐨勮В鍐沖姙娉曪細

  1. import matplotlib.pyplot as plt
  2. plt.ion() # 鎵撳紑浜や簰妯″紡
  3. # 鍚屾椂鎵撳紑涓や釜紿楀彛鏄劇ず鍥劇墖
  4. plt.figure()
  5. plt.imshow(i1)
  6. plt.figure()
  7. plt.imshow(i2)
  8. # 鏄劇ず鍓嶅叧鎺変氦浜掓ā寮?/span>
  9. plt.ioff()
  10. plt.show()

 Reference:
https://blog.csdn.net/wonengguwozai/article/details/79686062



鏉板摜 2018-12-17 06:10 鍙戣〃璇勮
]]>
Error:Cannot start process, the path specified for working directory is not a directoryhttp://www.shnenglu.com/guijie/archive/2018/11/05/216033.html鏉板摜鏉板摜Mon, 05 Nov 2018 01:59:00 GMThttp://www.shnenglu.com/guijie/archive/2018/11/05/216033.htmlhttp://www.shnenglu.com/guijie/comments/216033.htmlhttp://www.shnenglu.com/guijie/archive/2018/11/05/216033.html#Feedback0http://www.shnenglu.com/guijie/comments/commentRss/216033.htmlhttp://www.shnenglu.com/guijie/services/trackbacks/216033.htmlIf I open one file such as "hw3_prob4Sol.py", the code can run. However, there is an error: Cannot start process, the path specified for working directory is not a directory. I can use the following method to solve this problem.
PyCharm change working directory of console
Settings -> Build Execution Deployment -> Console -> Python Console

However, if I change the working directory every time, this gives me much trouble. Zhengxia is inspired by
"
I finally solved the problem.

I think it all started because the first project that I opened with pycharm was in my "download" folder, so the working directory was automatically set to a temporal folder by default and although I moved the project to another folder and I manually changed the working directory from the terminal, it was not working.

The solution was creating a new project and giving a correct path to the new project. It seems very easy but it was not that obvious." from https://stackoverflow.com/questions/28202273/working-directory-error/28975990.

He gave me the suggestion: File -> open, open the directory rather than open the file. For example, "
GAN\code\generative-models-master", he said that it is better to make the environment of the pycharm projects consistent (pycharm宸ョ▼榛樿鍔犺澆涓涓幆澧冨彉閲?鏈濂藉悓涓涓伐紼嬩笅鐜涓鑷?. Then a file ".idea" will be created. In this way, all files of this folder will be seen as a part of this project. In the file ".idea", there will be the historical record, the path setting such as the interpreter. Generally, we do not use this file.

Reference:
https://stackoverflow.com/questions/37818938/pycharm-change-working-directory-of-console


鏉板摜 2018-11-05 09:59 鍙戣〃璇勮
]]>
PyCharm skills: indentionhttp://www.shnenglu.com/guijie/archive/2018/10/14/216008.html鏉板摜鏉板摜Sat, 13 Oct 2018 21:08:00 GMThttp://www.shnenglu.com/guijie/archive/2018/10/14/216008.htmlhttp://www.shnenglu.com/guijie/comments/216008.htmlhttp://www.shnenglu.com/guijie/archive/2018/10/14/216008.html#Feedback0http://www.shnenglu.com/guijie/comments/commentRss/216008.htmlhttp://www.shnenglu.com/guijie/services/trackbacks/216008.htmlShift + Tab: Left indention
Sui Li says that word, powerpoint and group wiki (foreseer) also use this.

鏉板摜 2018-10-14 05:08 鍙戣〃璇勮
]]>
How to read *.mat file in python?http://www.shnenglu.com/guijie/archive/2018/10/14/216007.html鏉板摜鏉板摜Sat, 13 Oct 2018 20:47:00 GMThttp://www.shnenglu.com/guijie/archive/2018/10/14/216007.htmlhttp://www.shnenglu.com/guijie/comments/216007.htmlhttp://www.shnenglu.com/guijie/archive/2018/10/14/216007.html#Feedback0http://www.shnenglu.com/guijie/comments/commentRss/216007.htmlhttp://www.shnenglu.com/guijie/services/trackbacks/216007.htmlimport scipy.io as sio
mnist_49_3000 = sio.loadmat('mnist_49_3000.mat')


鏉板摜 2018-10-14 04:47 鍙戣〃璇勮
]]>
How to read *.data in Matlab and Pythonhttp://www.shnenglu.com/guijie/archive/2018/10/13/216005.html鏉板摜鏉板摜Fri, 12 Oct 2018 20:33:00 GMThttp://www.shnenglu.com/guijie/archive/2018/10/13/216005.htmlhttp://www.shnenglu.com/guijie/comments/216005.htmlhttp://www.shnenglu.com/guijie/archive/2018/10/13/216005.html#Feedback0http://www.shnenglu.com/guijie/comments/commentRss/216005.htmlhttp://www.shnenglu.com/guijie/services/trackbacks/216005.htmlSee P2 of "HW2_545_2018_"

In Matlab:
z = dlmread('spambase.data',',');
In Python:
import numpy as np
z = np.genfromtxt('spambase.data', dtype=float, delimiter=',')


鏉板摜 2018-10-13 04:33 鍙戣〃璇勮
]]>
product in python: np.dot, np.multiply, *http://www.shnenglu.com/guijie/archive/2018/10/06/215992.html鏉板摜鏉板摜Sat, 06 Oct 2018 00:33:00 GMThttp://www.shnenglu.com/guijie/archive/2018/10/06/215992.htmlhttp://www.shnenglu.com/guijie/comments/215992.htmlhttp://www.shnenglu.com/guijie/archive/2018/10/06/215992.html#Feedback0http://www.shnenglu.com/guijie/comments/commentRss/215992.htmlhttp://www.shnenglu.com/guijie/services/trackbacks/215992.htmlhttps://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.dot.html

Dot product of two arrays. Specifically,

  • If both a and b are 1-D arrays, it is inner product of vectors (without complex conjugation).

  • If both a and b are 2-D arrays, it is matrix multiplication, but using matmul or a @ b is preferred.

  • If either a or b is 0-D (scalar), it is equivalent to multiply and using numpy.multiply(a, b) or a * b is preferred.

  • If a is an N-D array and b is a 1-D array, it is a sum product over the last axis of a and b.

  • If a is an N-D array and b is an M-D array (where M>=2), it is a sum product over the last axis of a and the second-to-last axis of b:

    dot(a, b)[i,j,k,m] = sum(a[i,j,:] * b[k,:,m])
What does the last two points mean?
My understanding is that 2-D arrays are a matrix. N-D array is a tensor. The aforementioned example is very clear. Both a and b are 3-D arrays.

鏉板摜 2018-10-06 08:33 鍙戣〃璇勮
]]>
Interpreter of Pycharmhttp://www.shnenglu.com/guijie/archive/2018/10/05/215990.html鏉板摜鏉板摜Fri, 05 Oct 2018 00:59:00 GMThttp://www.shnenglu.com/guijie/archive/2018/10/05/215990.htmlhttp://www.shnenglu.com/guijie/comments/215990.htmlhttp://www.shnenglu.com/guijie/archive/2018/10/05/215990.html#Feedback0http://www.shnenglu.com/guijie/comments/commentRss/215990.htmlhttp://www.shnenglu.com/guijie/services/trackbacks/215990.htmlYang Zhou says that there can be infinity python.exe in your computer. Maybe some install numpy while some not.
Some other interpreters on my computer: 
C:\Users\think\PycharmProjects\Test\venv\Scripts\python.exe       Even if I reinstall my operating system, the files in C:\Users\think\PycharmProjects do not need to be stored since this in an empty project.
E:\OneDrive - ustc.edu\PycharmProjects\Test\venv\Scripts
I have set C:\Users\think\Anaconda3\python.exe as the default interpreter. This interpreter has installed numpy. How can we set this? pycharm -> File -> Default settings
pycharm -> File -> settings -> show all -> existing environment
One interesting fact is that if I name a directory as _numpy and "import numpy as np" will have error. This error can be solved by changing the name of the directory from _numpy to _numpy1.

Reference:
https://blog.csdn.net/chengzihe_lu/article/details/79639804




鏉板摜 2018-10-05 08:59 鍙戣〃璇勮
]]>
pycharm 榛樿甯冨眬涔變簡http://www.shnenglu.com/guijie/archive/2018/08/28/215883.html鏉板摜鏉板摜Mon, 27 Aug 2018 21:26:00 GMThttp://www.shnenglu.com/guijie/archive/2018/08/28/215883.htmlhttp://www.shnenglu.com/guijie/comments/215883.htmlhttp://www.shnenglu.com/guijie/archive/2018/08/28/215883.html#Feedback0http://www.shnenglu.com/guijie/comments/commentRss/215883.htmlhttp://www.shnenglu.com/guijie/services/trackbacks/215883.html鑿滃崟  Window>restore default layout銆備絾鏄垜鐨勮彍鍗曟爮娌℃湁window銆備貢鐐癸紝鑿滃崟鏍忎笅闈竴琛屽彸閿紝鏈塁ustomize Menus and Toolbars錛?Restore All Defaults銆傝彍鍗曟爮灝辨湁浜哤indow

鏉板摜 2018-08-28 05:26 鍙戣〃璇勮
]]>
matlab errorbarhttp://www.shnenglu.com/guijie/archive/2012/09/06/189645.html鏉板摜鏉板摜Thu, 06 Sep 2012 01:28:00 GMThttp://www.shnenglu.com/guijie/archive/2012/09/06/189645.htmlhttp://www.shnenglu.com/guijie/comments/189645.htmlhttp://www.shnenglu.com/guijie/archive/2012/09/06/189645.html#Feedback0http://www.shnenglu.com/guijie/comments/commentRss/189645.htmlhttp://www.shnenglu.com/guijie/services/trackbacks/189645.html

On the group meeting of Oct 3, 2018, Jiaqi shows his bar. I asked that why his variance is very small. He said that he uses the standard error (https://en.wikipedia.org/wiki/Standard_error), which is standard derivation divided by the square root of the number of trials. According to the notes of my undergraduate course probability:
(1) D(ax+b) = a*a*D(x),
(2) the second line of "涓績鏋侀檺瀹氱悊". x bar is seen as a random variable,
we have std(x bar) = std(x)/sqrt(n).
I ask Jiaqi which tool he uses to draw his figure. He says he uses python, bar of matplotlib. https://matplotlib.org/api/_as_gen/matplotlib.pyplot.bar.html. The mean of the errors and standard error should be computed first and then be used as the input of xerr and yerr. 
I check my TNNLS 2017 paper and I find that I show the std. Maybe next time I can show the standard error.


榪欎釜鍑芥暟鐨勬剰鎬濇槸錛?br />ERRORBAR(X,Y,L,U)錛孹鏄嚜鍙橀噺錛孻鏄洜鍙橀噺錛孡鏄痀鐨勫彉鍔ㄤ笅闄愶紝U鏄痀鐨勫彉鍔ㄤ笂闄?/p>

errorbar(X,Y,E)  X鏄嚜鍙橀噺錛孻鏄洜鍙橀噺錛孍鏄痀鐨勫彉鍔ㄧ粷瀵瑰樊鍊箋?/p>鎴戣嚜宸卞啓鐨勪緥瀛愶細

 X=[1 2 3];
Y= [ 0.2 0.4 0.2];
L=[0.1 0.03 0.03];U=[0.1 0.3 0.2];
E= [0.1 0.3 0.2];
figure;
hold on;%涓瀹氳鏈夎繖涓鍙ワ紝鍚﹀垯鏈夐棶棰?/div>
bar(X,Y);
errorbar(X,Y,E,'Marker','none','LineStyle','none');
figure;
hold on;%涓瀹氳鏈夎繖涓鍙ワ紝鍚﹀垯鏈夐棶棰?/div>
errorbar(X,Y,E);%浠ヤ笅娉ㄩ噴鐨勪袱鍙ョ敤榪欎竴鍙ュ氨鍙互浜?br />%plot(X,Y);
%errorbar(X,Y,E,'Marker','none','LineStyle','none');
figure;
hold on;%涓瀹氳鏈夎繖涓鍙ワ紝鍚﹀垯鏈夐棶棰?/div>
bar(X,Y);
errorbar(X,Y,L,U);%,'Marker','none','LineStyle','none'涓嶈兘鐪?/div>
璇存槑錛氬繀欏諱嬌鐢╤old on錛宐ar鏄敾鏌辯姸鍥撅紝 errorbar鏄姳绔栫嚎
--------------------------------------------------------------------浠ヤ笅鍙笉鐪?---------------------------------------------------------------------------
example1錛?/span>

 

       x = 1:10;
       y = sin(x);
       e = std(y)*ones(size(x));
       errorbar(x,y,e)

 

matlab鐨別rrorbar鍑芥暟

example2錛?/span> 
% 鐢熸垚紺轟緥鏁版嵁
x=1:10;
y=cumsum(randn(1,10));
lower = y - (rand(1,10));
upper = y + (rand(1,10));

% 鐢變簬errorbar鍑芥暟浣跨敤鐩稿宸煎湪鍥懼艦涓婄粯鍥撅紝鎵浠?/span>
% 闇瑕佸皢緇濆宸艱漿鍙樹負鐩稿宸箋?/span>
L = y - lower;
U = upper -y;

% 緇樺浘鏃墮渶瑕佽瀹?hold on
% 鏌辯姸鍥?/span>
clf;
figure(1);
hold on;
bar(x,y);
% 姝ゅ闇瑕侀殣钘忔姌綰?/span>
errorbar(x,y,L,U,'Marker','none','LineStyle','none');

% 鎶樼嚎鍥?/span>
figure(2);
hold('on');
plot( x, y);
errorbar( x, y, L, U); 

Reference:
http://blog.sina.com.cn/s/blog_61010ebe0100l9c9.html 
http://bio-spring.info/wp/?p=85 

鏉板摜 2012-09-06 09:28 鍙戣〃璇勮
]]>Python path; matlab function load, savehttp://www.shnenglu.com/guijie/archive/2012/06/20/179529.html鏉板摜鏉板摜Wed, 20 Jun 2012 13:07:00 GMThttp://www.shnenglu.com/guijie/archive/2012/06/20/179529.htmlhttp://www.shnenglu.com/guijie/comments/179529.htmlhttp://www.shnenglu.com/guijie/archive/2012/06/20/179529.html#Feedback0http://www.shnenglu.com/guijie/comments/commentRss/179529.htmlhttp://www.shnenglu.com/guijie/services/trackbacks/179529.htmlmatlab鍑芥暟load 鐩綍錛宻ave
鐩綍閮界敤鍙嶆枩鏉狅紝榪欐牱windows鍜孡inux鐩綍閮借錛孡inux鍙鍙嶆枩鏉?nbsp;
褰撳墠鐩綍錛?/span>
for s=1:20
    filename = num2str(s);
    load (filename);
end
褰撳墠鐩綍鐨勪笅涓灞傜洰褰?/span>錛?/span>
for s=1:20
    %filename = ['./50Train/',num2str(s),'.mat'];  %榪欑鏂瑰紡搴旇鏇村揩錛岀渷寰楀瓧絎︿覆鎿嶄綔
    %filename = ['50Train/',num2str(s)];    %鏈鍓嶉潰鐨?/涓嶅姞涔熷彲浠?/span>
    %filename = ['./50Train/',num2str(s)];
    filename = strcat('./50Train/',num2str(s));
    load (filename);
end
褰撳墠鐩綍鐨勪笂涓灞傜洰褰曪細
for s=1:20
    %filename = ['../50Train/',num2str(s),'.mat']; 
    %filename = ['../50Train/',num2str(s)];
    filename = strcat('../50Train/',num2str(s));
    load (filename);
end

dataName = '../Parmprint.mat';%'../Parmprint/'鍜?/span>Parmprint.mat/'閮戒笉琛?/span>
渚嬶細caffe-master-20151202\caffe-master\matlab\demo\classification_demo.m,  im = imread('../../examples/images/cat.jpg');
----------------------------------------------------------------------
  鎯崇紪涓涓驚鐜紝姣忎釜鏂囦歡鍚嶄緷嬈℃槸1錛?錛岀瓑鍒皀um
for i =1:num
    savefile = [num2str(i),'.mat'];
    save(savefile, 'trainIdx', 'testIdx');%trainIdx 鍜宼estIdx 鍙互鏄叾浠栦換浣曞彉閲?br />end

save鐨勫悕瀛椾腑鍚湁灝忔暟鐐?/span>
ratio = 0.01;
savefile = ['NFL_ASLAN',num2str(ratio),'.mat'];
save(savefile, 'accuracy');
瑙佹垜鐨刴atlab鏁欐潗P20 


Python path
If I put Homework2Q2.py in another content(鐩綍) and I use the "E:\OneDrive - ustc.edu\Lecture\ustc\Artificial intelligence related\Machine learning\Umich\..."in line 4, there is an error as follows:
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 30-31: truncated \uXXXX escape
Zhou Yang says that in Python '\n' has a specific meaning. Similarly, python will think '\u' and '\U' has a specific meaning. Write '\\u' and '\\U' instead. Zhengxia says that there are two other ways to solve this problem:
(1) r'E:\OneDrive - ustc.edu\Lecture\ustc\Artificial intelligence related\Machine learning\Umich\...'
(2) use / rather than \


鏉板摜 2012-06-20 21:07 鍙戣〃璇勮
]]> 青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
      <noscript id="pjuwb"></noscript>
            <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
              <dd id="pjuwb"></dd>
              <abbr id="pjuwb"></abbr>
              美女视频网站黄色亚洲| 日韩视频一区二区三区在线播放| 亚洲天堂免费观看| 亚洲精品久久久久久久久久久久久| 亚洲自拍偷拍视频| 欧美国产日韩一区二区| 国产欧美日韩亚州综合| 久久精品夜色噜噜亚洲aⅴ| 午夜精品区一区二区三| 国内精品国语自产拍在线观看| 久久一区二区三区国产精品| 久久久久久久综合狠狠综合| 亚洲精品男同| 亚洲最黄网站| 国产专区一区| 91久久综合亚洲鲁鲁五月天| 欧美香蕉大胸在线视频观看| 久久国产精品久久久久久久久久| 久久久久久久综合日本| 一区二区三区免费网站| 亚洲影院污污.| 亚洲黄色性网站| 在线综合视频| 在线精品视频一区二区| 99re66热这里只有精品4| 国产精品综合视频| 亚洲国产精品免费| 国产老女人精品毛片久久| 欧美成人黄色小视频| 欧美三区在线视频| 美女久久一区| 国产精品尤物福利片在线观看| 久久综合久久综合久久综合| 欧美日韩美女| 欧美11—12娇小xxxx| 国产精品久久久亚洲一区| 老司机免费视频一区二区| 国产精品99一区二区| 欧美v国产在线一区二区三区| 国产精品久久久久永久免费观看| 欧美激情中文不卡| 国产亚洲欧美另类中文| 日韩一级免费| 亚洲欧洲另类国产综合| 欧美一区深夜视频| 亚洲欧美经典视频| 欧美人与性动交cc0o| 裸体丰满少妇做受久久99精品| 国产精品二区影院| 亚洲日韩视频| 亚洲精品久久久久久久久| 欧美一级黄色网| 午夜精品久久一牛影视| 欧美日韩国产小视频| 欧美激情精品久久久久久黑人| 国产午夜精品在线| 欧美一区成人| 欧美一区视频| 国产精品一区在线观看你懂的| 一区二区冒白浆视频| 日韩视频免费| 欧美美女视频| 99re热这里只有精品免费视频| 久久精品欧洲| 99re热这里只有精品免费视频| 午夜精品一区二区三区在线| 在线观看精品一区| 悠悠资源网久久精品| 亚洲精品九九| 亚洲免费观看高清完整版在线观看熊| 久久久青草婷婷精品综合日韩| 久久躁日日躁aaaaxxxx| 精品91视频| 噜噜噜躁狠狠躁狠狠精品视频| 欧美激情一区在线观看| 亚洲免费不卡| 欧美午夜在线观看| 午夜精品剧场| 久久一日本道色综合久久| 在线欧美小视频| 免费亚洲婷婷| 99精品欧美一区二区三区综合在线 | 91久久久久久久久久久久久| 亚洲精品日产精品乱码不卡| 欧美激情欧美狂野欧美精品| 亚洲精品一区二区三区樱花| 亚洲尤物在线| 国产亚洲激情在线| 久久综合九色| 中文精品视频| 久久午夜精品一区二区| 亚洲人午夜精品免费| 欧美日韩精品一区二区三区四区| 亚洲午夜黄色| 欧美mv日韩mv国产网站app| 99国产精品一区| 国产乱子伦一区二区三区国色天香 | 亚洲网站在线观看| 久久人人爽人人| 亚洲精品在线一区二区| 国产精品九色蝌蚪自拍| 久久精品盗摄| 99在线精品视频| 久久免费精品日本久久中文字幕| 亚洲三级电影全部在线观看高清| 国产精品v欧美精品v日本精品动漫| 先锋亚洲精品| 亚洲免费观看高清完整版在线观看熊| 欧美伊人久久久久久久久影院 | 国产精品久久久久久久app| 久久国产一区二区| 亚洲精品久久久蜜桃| 久久久久久国产精品mv| 一区二区高清在线观看| 精品96久久久久久中文字幕无| 欧美日韩天天操| 久久久久久免费| 亚洲专区免费| 亚洲人成人99网站| 欧美成人午夜剧场免费观看| 亚洲男女自偷自拍图片另类| 亚洲国产精品欧美一二99| 国产欧美一区二区精品婷婷| 欧美日本免费一区二区三区| 久久久噜噜噜久久中文字免| 亚洲一区二区三区免费视频 | 欧美特黄一区| 欧美精品18| 美女尤物久久精品| 久久久免费精品视频| 亚洲欧美日韩精品久久| 一区二区三区久久精品| 亚洲精品乱码| 亚洲精品一二| 亚洲国产综合在线看不卡| 免费短视频成人日韩| 久久蜜桃资源一区二区老牛| 欧美在线一二三区| 欧美一区二区三区四区在线| 亚洲一区二区三区影院| 一本色道久久综合亚洲精品小说| 亚洲国产91色在线| 亚洲高清123| 亚洲黑丝在线| 亚洲精品欧美日韩专区| 亚洲国产美女| 亚洲精品一线二线三线无人区| 亚洲国产另类久久久精品极度 | 欧美日韩视频在线第一区| 欧美理论视频| 欧美日韩中字| 国产精品久久久久久久午夜| 国产精品区一区| 国产亚洲电影| 激情久久久久久久| 亚洲国产精品一区二区尤物区| 亚洲国产精品小视频| 亚洲啪啪91| 亚洲一区日韩| 久久精品国产综合| 欧美+日本+国产+在线a∨观看| 欧美激情国产日韩| 99爱精品视频| 午夜精品久久久久久| 久久久久久9999| 欧美国产日韩一区二区| 欧美婷婷六月丁香综合色| 国产精品视频午夜| 在线欧美影院| 一区二区三区日韩精品| 小黄鸭精品aⅴ导航网站入口| 久久久噜噜噜| 亚洲毛片av在线| 亚洲欧美制服另类日韩| 久热这里只精品99re8久| 欧美日本网站| 激情久久综艺| 亚洲综合视频一区| 欧美激情精品久久久久久久变态| 在线一区二区三区做爰视频网站| 久久久国产午夜精品| 国产精品高潮呻吟| 亚洲国产精品一区制服丝袜 | 欧美激情第1页| 亚洲欧美日韩国产精品| 免费观看亚洲视频大全| 国产欧美精品国产国产专区| 最新国产成人av网站网址麻豆| 欧美亚洲免费在线| 亚洲欧洲日本在线| 久久久久国产一区二区三区| 国产精品xnxxcom| 亚洲二区在线视频| 欧美中文字幕在线| 亚洲日本中文字幕| 免费成人av资源网| 伊人春色精品| 久久国产天堂福利天堂| 亚洲成色www8888| 性感少妇一区|