久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<i id='TMDyx'><tr id='TMDyx'><dt id='TMDyx'><q id='TMDyx'><span id='TMDyx'><b id='TMDyx'><form id='TMDyx'><ins id='TMDyx'></ins><ul id='TMDyx'></ul><sub id='TMDyx'></sub></form><legend id='TMDyx'></legend><bdo id='TMDyx'><pre id='TMDyx'><center id='TMDyx'></center></pre></bdo></b><th id='TMDyx'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='TMDyx'><tfoot id='TMDyx'></tfoot><dl id='TMDyx'><fieldset id='TMDyx'></fieldset></dl></div>

  • <small id='TMDyx'></small><noframes id='TMDyx'>

      <legend id='TMDyx'><style id='TMDyx'><dir id='TMDyx'><q id='TMDyx'></q></dir></style></legend>
      <tfoot id='TMDyx'></tfoot>
      • <bdo id='TMDyx'></bdo><ul id='TMDyx'></ul>
      1. 在 Python 中從同一類中的另一個調用一個方法

        Calling one method from another within same class in Python(在 Python 中從同一類中的另一個調用一個方法)
          <tfoot id='phoEo'></tfoot>

            <small id='phoEo'></small><noframes id='phoEo'>

            <legend id='phoEo'><style id='phoEo'><dir id='phoEo'><q id='phoEo'></q></dir></style></legend>
              <bdo id='phoEo'></bdo><ul id='phoEo'></ul>

              1. <i id='phoEo'><tr id='phoEo'><dt id='phoEo'><q id='phoEo'><span id='phoEo'><b id='phoEo'><form id='phoEo'><ins id='phoEo'></ins><ul id='phoEo'></ul><sub id='phoEo'></sub></form><legend id='phoEo'></legend><bdo id='phoEo'><pre id='phoEo'><center id='phoEo'></center></pre></bdo></b><th id='phoEo'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='phoEo'><tfoot id='phoEo'></tfoot><dl id='phoEo'><fieldset id='phoEo'></fieldset></dl></div>
                  <tbody id='phoEo'></tbody>

                • 本文介紹了在 Python 中從同一類中的另一個調用一個方法的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我對 python 很陌生.我試圖在類中將值從一種方法傳遞給另一種方法.我搜索了這個問題,但我無法得到正確的解決方案.因為在我的代碼中,if"正在調用類的方法on_any_event",作為回報應該調用我的另一個方法dropbox_fn",該方法利用on_any_event"中的值.如果dropbox_fn"方法在類外,它會起作用嗎?

                  I am very new to python. I was trying to pass value from one method to another within the class. I searched about the issue but i could not get proper solution. Because in my code, "if" is calling class's method "on_any_event" that in return should call my another method "dropbox_fn", which make use of the value from "on_any_event". Will it work, if the "dropbox_fn" method is outside the class?

                  我會用代碼來說明.

                  class MyHandler(FileSystemEventHandler):
                   def on_any_event(self, event):
                      srcpath=event.src_path
                      print (srcpath, 'has been ',event.event_type)
                      print (datetime.datetime.now())
                      #print srcpath.split(' ', 12 );
                      filename=srcpath[12:]
                      return filename # I tried to call the method. showed error like not callable 
                  
                   def dropbox_fn(self)# Or will it work if this methos is outside the class ?
                      #this method uses "filename"
                  
                  if __name__ == "__main__":
                    path = sys.argv[1] if len(sys.argv) > 1 else '.'
                    print ("entry")
                    event_handler = MyHandler()
                    observer = Observer()
                    observer.schedule(event_handler, path, recursive=True)
                    observer.start()
                    try:
                       while True:
                           time.sleep(1)
                    except KeyboardInterrupt:
                      observer.stop()
                    observer.join()
                  

                  這里的主要問題是.. 我不能在沒有事件參數的情況下調用on_any_event"方法.因此,與其返回值,不如在on_any_event"中調用dropbox_fn"是一種更好的方法.有人可以幫忙嗎?

                  The main issue in here is.. I cannot call "on_any_event" method without event parameter. So rather than returning value, calling "dropbox_fn" inside "on_any_event" would be a better way. Can someone help with this?

                  推薦答案

                  要調用該方法,您需要使用 self. 限定函數.除此之外,如果要傳遞文件名,請添加 filename 參數(或您想要的其他名稱).

                  To call the method, you need to qualify function with self.. In addition to that, if you want to pass a filename, add a filename parameter (or other name you want).

                  class MyHandler(FileSystemEventHandler):
                  
                      def on_any_event(self, event):
                          srcpath = event.src_path
                          print (srcpath, 'has been ',event.event_type)
                          print (datetime.datetime.now())
                          filename = srcpath[12:]
                          self.dropbox_fn(filename) # <----
                  
                      def dropbox_fn(self, filename):  # <-----
                          print('In dropbox_fn:', filename)
                  

                  這篇關于在 Python 中從同一類中的另一個調用一個方法的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to make a discord bot that gives roles in Python?(如何制作一個在 Python 中提供角色的不和諧機器人?)
                  Discord bot isn#39;t responding to commands(Discord 機器人沒有響應命令)
                  Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關于我嗎?Discord 機器人的功能?(不和諧.py))
                  message.channel.id Discord PY(message.channel.id Discord PY)
                  How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機器人?)
                  discord.py - Automaticaly Change an Role Color(discord.py - 自動更改角色顏色)
                • <tfoot id='IxfiG'></tfoot>

                  <small id='IxfiG'></small><noframes id='IxfiG'>

                  • <legend id='IxfiG'><style id='IxfiG'><dir id='IxfiG'><q id='IxfiG'></q></dir></style></legend>

                        <tbody id='IxfiG'></tbody>

                        • <bdo id='IxfiG'></bdo><ul id='IxfiG'></ul>
                          <i id='IxfiG'><tr id='IxfiG'><dt id='IxfiG'><q id='IxfiG'><span id='IxfiG'><b id='IxfiG'><form id='IxfiG'><ins id='IxfiG'></ins><ul id='IxfiG'></ul><sub id='IxfiG'></sub></form><legend id='IxfiG'></legend><bdo id='IxfiG'><pre id='IxfiG'><center id='IxfiG'></center></pre></bdo></b><th id='IxfiG'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='IxfiG'><tfoot id='IxfiG'></tfoot><dl id='IxfiG'><fieldset id='IxfiG'></fieldset></dl></div>
                          1. 主站蜘蛛池模板: 五月天激情综合网 | 蜜月aⅴ免费一区二区三区 99re在线视频 | 国产色婷婷精品综合在线手机播放 | 欧美freesex黑人又粗又大 | 美女拍拍拍网站 | 欧美中文字幕一区二区 | 国产精品成人久久久久 | 情侣酒店偷拍一区二区在线播放 | 综合色婷婷| 九九久久99| 综合精品 | 国产精品久久久久久吹潮 | 91精品国产手机 | 自拍偷拍亚洲视频 | a级大片 | 日韩在线免费视频 | 九九免费视频 | 亚洲综合在线播放 | 神马影院一区二区三区 | 中文字幕一区二区三区乱码在线 | 91精品国产欧美一区二区成人 | 成人小视频在线观看 | 国产一区精品 | 日韩中文字幕一区 | 中国大陆高清aⅴ毛片 | 蜜桃av一区二区三区 | av成人在线观看 | 国产一级片在线播放 | 久久午夜视频 | 蜜臀网| 久久亚| 在线播放国产一区二区三区 | 亚洲 欧美 在线 一区 | 成人一区二区三区在线观看 | 一级网站| 久久久成人免费一区二区 | 国产精品久久久久久久久 | 国产精品欧美精品 | 精品中文视频 | 中文字幕在线电影观看 | 一本大道久久a久久精二百 国产成人免费在线 |