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

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

          <bdo id='Gdtn0'></bdo><ul id='Gdtn0'></ul>
        <i id='Gdtn0'><tr id='Gdtn0'><dt id='Gdtn0'><q id='Gdtn0'><span id='Gdtn0'><b id='Gdtn0'><form id='Gdtn0'><ins id='Gdtn0'></ins><ul id='Gdtn0'></ul><sub id='Gdtn0'></sub></form><legend id='Gdtn0'></legend><bdo id='Gdtn0'><pre id='Gdtn0'><center id='Gdtn0'></center></pre></bdo></b><th id='Gdtn0'></th></span></q></dt></tr></i><div id='Gdtn0'><tfoot id='Gdtn0'></tfoot><dl id='Gdtn0'><fieldset id='Gdtn0'></fieldset></dl></div>
      1. <legend id='Gdtn0'><style id='Gdtn0'><dir id='Gdtn0'><q id='Gdtn0'></q></dir></style></legend>

        为什么这个 ctypes 代码不能与 Python 3.3 一起使用,但可以与 Python 2.7 一起使用?

        Why won#39;t this ctypes code work with Python 3.3 but will work with Python 2.7?(为什么这个 ctypes 代码不能与 Python 3.3 一起使用,但可以与 Python 2.7 一起使用?)
      2. <small id='UBocw'></small><noframes id='UBocw'>

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

              <tbody id='UBocw'></tbody>

            <legend id='UBocw'><style id='UBocw'><dir id='UBocw'><q id='UBocw'></q></dir></style></legend>
          • <tfoot id='UBocw'></tfoot>
              • <bdo id='UBocw'></bdo><ul id='UBocw'></ul>
                  本文介绍了为什么这个 ctypes 代码不能与 Python 3.3 一起使用,但可以与 Python 2.7 一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  所以我正在尝试制作一个 Python 3.3 程序来使用 ctypes 模块更改 Windows 桌面背景.我已经在 Python 2.7 中测试了以下代码,并且运行良好.但它不适用于 Python 3.3!我使用的是 Windows 7.这是代码:

                  So I'm trying to make a Python 3.3 program to change the Windows desktop background using the ctypes module. I've tested the following code in Python 2.7, and it worked perfectly. But it just won't work with Python 3.3! I'm using Windows 7. Here's the code:

                  import ctypes
                  SPI_SETDESKTOPWALLPAPER=20
                  ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKTOPWALLPAPER, 0,"C:/Users/Public/Pictures/Sample Pictures/Penguins.jpg", 3)
                  

                  推荐答案

                  SystemParametersInfoA 需要一个 8 位 ANSI 编码的输入字符串作为参数,即 mbcsPython 中的编码.

                  SystemParametersInfoA requires a 8-bit ANSI encoded input string as a parameter, which is known as mbcs encoding in Python.

                  您将不得不在 python3 中使用 SystemParametersInfoW.这是因为 SystemParametersInfoW 接受一个 UTF-16 宽的字符串(在 C 中是 wchar_t *)并且 ctypes 库会自动转换这个传递的 unicodec_wchar_p 中的参数.

                  You will have to use SystemParametersInfoW in python3. This is because SystemParametersInfoW takes in a UTF-16 wide string (which is wchar_t * in C) and the ctypes library automatically converts this passed unicode argument into c_wchar_p.

                  请参阅 文档更多细节.

                  这篇关于为什么这个 ctypes 代码不能与 Python 3.3 一起使用,但可以与 Python 2.7 一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                  Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)

                    <tfoot id='pJqut'></tfoot>

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

                        <legend id='pJqut'><style id='pJqut'><dir id='pJqut'><q id='pJqut'></q></dir></style></legend>
                        <i id='pJqut'><tr id='pJqut'><dt id='pJqut'><q id='pJqut'><span id='pJqut'><b id='pJqut'><form id='pJqut'><ins id='pJqut'></ins><ul id='pJqut'></ul><sub id='pJqut'></sub></form><legend id='pJqut'></legend><bdo id='pJqut'><pre id='pJqut'><center id='pJqut'></center></pre></bdo></b><th id='pJqut'></th></span></q></dt></tr></i><div id='pJqut'><tfoot id='pJqut'></tfoot><dl id='pJqut'><fieldset id='pJqut'></fieldset></dl></div>
                          <bdo id='pJqut'></bdo><ul id='pJqut'></ul>
                            <tbody id='pJqut'></tbody>