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

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

    1. <tfoot id='hLggQ'></tfoot>

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

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

        multiprocessing.value 語法清晰嗎?

        multiprocessing.value clear syntax?(multiprocessing.value 語法清晰嗎?)

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

          <bdo id='W8oyS'></bdo><ul id='W8oyS'></ul>

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

            1. <tfoot id='W8oyS'></tfoot>
                • <legend id='W8oyS'><style id='W8oyS'><dir id='W8oyS'><q id='W8oyS'></q></dir></style></legend>
                • 本文介紹了multiprocessing.value 語法清晰嗎?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我想使用 multiprocessing.Value 在多個進程中使用變量,但 Python 文檔中的語法并不清楚.誰能告訴我應該使用什么類型(我的變量是一個字母),以及將變量名放在哪里?

                  I want to use?multiprocessing.Value?to use a variable in multiple processes, but the syntax is not clear on Python's documentation. Can anyone tell me what should I use as type (my variable is a letter), and where to put my variable's name ?

                  編輯

                  我嘗試使用管理器在進程之間共享我的信件.但我現在唯一擁有的是在 Python Shell 中打印的 Value('ctypes.c_char_p', '(The key you hit here)') 仍然沒有聲音.使用管理器時,控制臺似乎也比平時慢了一點.在我按下鍵和 Value 出現在屏幕上之間,有將近一秒的延遲.

                  I tried using the?Manager?to share my letter between processes. But the only thing I have now is Value('ctypes.c_char_p', '(The key you hit here)')?printed in the Python Shell and still no sound. The console also seems a bit slower than usual when using the manager. There's an almost one second delay between the time I hit the key and when the Value appears on screen.

                  我的代碼現在看起來像這樣:

                  My code now looks like this :

                  #Import 
                  from tkinter import * 
                  import wave 
                  import winsound 
                  import multiprocessing 
                  
                  #Functions 
                  
                  def key(event):
                  
                       temp = event.char
                       manager = multiprocessing.Manager()
                       manager.Value(ctypes.c_char_p, temp)
                       hitkey = manager.Value(ctypes.c_char_p, temp)
                       instance = multiprocessing.Process(target=player, args=(hitkey,)) 
                       instance.start()
                  
                  
                  
                  def player(hitkey):
                       print(hitkey + "1")
                       winsound.PlaySound(hitkey + '.wav', winsound.SND_FILENAME|winsound.SND_NOWAIT|winsound.SND_ASYNC) 
                  
                  
                  if __name__ == "__main__":
                  
                  
                  
                       #Initialisation 
                       fenetre = Tk() 
                       frame = Frame(fenetre, width=200, height=100)
                       #TK
                  
                       frame.focus_set()
                       frame.bind("<Key>", key)
                       frame.pack()
                       fenetre.mainloop()
                  

                  推薦答案

                  multiprocessing.Value,它只是一個和其他類一樣的類.Value 構造函數的簽名 描述得非常完美:

                  multiprocessing.Value(typecode_or_type, *args[, lock])

                  返回一個從共享內存分配的 ctypes 對象.默認情況下,返回值實際上是對象的同步包裝器.

                  Return a ctypes object allocated from shared memory. By default the return value is actually a synchronized wrapper for the object.

                  typecode_or_type 確定返回對象的類型:它是 ctypes 類型或所用類型的單字符類型代碼由 array 模塊.*args 被傳遞給構造函數輸入.

                  typecode_or_type determines the type of the returned object: it is either a ctypes type or a one character typecode of the kind used by the array module. *args is passed on to the constructor for the type.

                  如果 lockTrue(默認值),則創建一個新的鎖對象以同步對值的訪問.如果 lock 是 LockRLock 對象然后將用于同步訪問價值.如果 lockFalse 則訪問返回的對象將不會被鎖自動保護,所以不一定過程安全".

                  If lock is True (the default) then a new lock object is created to synchronize access to the value. If lock is a Lock or RLock object then that will be used to synchronize access to the value. If lock is False then access to the returned object will not be automatically protected by a lock, so it will not necessarily be "process-safe".

                  您甚至還有一些使用示例之后.特別是 typecode_or_type 可以是 array 模塊(例如 'i' 用于有符號整數,'f' 用于浮點等)或ctypes 類型,如 ctypes.c_int 等.

                  You even have some examples of its use afterwards. In particolar the typecode_or_type can be one of the typecodes that are listed in the documentation for the array module(e.g. 'i' for signed integer, 'f' for float etc.) or a ctypes type, like ctypes.c_int etc.

                  如果你想要一個包含單個字母的 Value,你可以這樣做:

                  If you want to have a Value containing a single letter you can do:

                  >>> import multiprocessing as mp
                  >>> letter = mp.Value('c', 'A')
                  >>> letter
                  <Synchronized wrapper for c_char('A')>
                  >>> letter.value
                  'A'
                  

                  更新

                  您的代碼的問題是類型代碼 'c' 表示字符 not 字符串.如果你想保存一個字符串,你可以使用類型 ctypes.c_char_p:

                  The problem with your code is that the typecode 'c' means character not string. If you want to hold a string you can use the type ctypes.c_char_p:

                  >>> import multiprocessing as mp
                  >>> import ctypes
                  >>> v = mp.Value('c', "Hello, World!")
                  Traceback (most recent call last):
                    File "<stdin>", line 1, in <module>
                    File "/usr/lib/python2.7/multiprocessing/__init__.py", line 253, in Value
                      return Value(typecode_or_type, *args, **kwds)
                    File "/usr/lib/python2.7/multiprocessing/sharedctypes.py", line 99, in Value
                      obj = RawValue(typecode_or_type, *args)
                    File "/usr/lib/python2.7/multiprocessing/sharedctypes.py", line 73, in RawValue
                      obj.__init__(*args)
                  TypeError: one character string expected
                  >>> v = mp.Value(ctypes.c_char_p, "Hello, World!")
                  >>> v
                  <Synchronized wrapper for c_char_p(166841564)>
                  >>> v.value
                  'Hello, World!'
                  

                  對于 Python 3,使用 c_wchar_p 代替 c_char_p

                  這篇關于multiprocessing.value 語法清晰嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  What exactly is Python multiprocessing Module#39;s .join() Method Doing?(Python 多處理模塊的 .join() 方法到底在做什么?)
                  Passing multiple parameters to pool.map() function in Python(在 Python 中將多個參數傳遞給 pool.map() 函數)
                  multiprocessing.pool.MaybeEncodingError: #39;TypeError(quot;cannot serialize #39;_io.BufferedReader#39; objectquot;,)#39;(multiprocessing.pool.MaybeEncodingError: TypeError(cannot serialize _io.BufferedReader object,)) - IT屋-程序員軟件開
                  Python Multiprocess Pool. How to exit the script when one of the worker process determines no more work needs to be done?(Python 多進程池.當其中一個工作進程確定不再需要完成工作時,如何退出腳本?) - IT屋-程序員
                  How do you pass a Queue reference to a function managed by pool.map_async()?(如何將隊列引用傳遞給 pool.map_async() 管理的函數?)
                  yet another confusion with multiprocessing error, #39;module#39; object has no attribute #39;f#39;(與多處理錯誤的另一個混淆,“模塊對象沒有屬性“f)

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

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

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

                          • 主站蜘蛛池模板: 日本不卡一区 | 超碰免费观看 | 黄色网址在线播放 | 久久精品免费 | 亚州毛片 | 视频一区 国产精品 | av一区二区三区 | 久久久女女女女999久久 | 国产午夜精品久久久久免费视高清 | 天天精品综合 | 国产精品免费一区二区三区四区 | 最新超碰 | 国产精品久久久久久久久大全 | 国产成人综合久久 | 亚洲精品免费在线观看 | 亚洲第一中文字幕 | 先锋资源站 | 国产精品一区免费 | 国产精品久久久久久久久久久久久久 | 亚洲免费一区 | 97caoporn国产免费人人 | 久久99精品久久久久久秒播九色 | 亚洲国产成人精品女人久久久 | 免费观看黄网站 | 欧美日韩视频在线 | 久视频在线观看 | 一区欧美| 亚洲一区二区三区视频 | 亚洲国产成人精品女人 | 国产精彩视频一区 | 国产一级片一区二区三区 | 国产精品成人一区 | 韩国久久精品 | 国产中文字幕网 | 精品国产乱码久久久久久蜜柚 | 久久三级av | 久久只有精品 | 久久久久久高潮国产精品视 | 在线免费亚洲视频 | 久久久久久久久久久成人 | 亚洲福利av |