小编Luc*_*cas的帖子

repr的输出何时有用?

我一直在阅读reprPython.我想知道输出的应用是什么repr.例如

class A:
 pass

repr(A) ='<class __main__.A at 0x6f570>'

b=A()
repr(b) = '<__main__.A instance at 0x74d78>'
Run Code Online (Sandbox Code Playgroud)

什么时候会对'<class __main__.A at 0x6f570>'或感兴趣'<__main__.A instance at 0x74d78>'

python repr

5
推荐指数
2
解决办法
876
查看次数

调试XAML UnhandledException

有时,由于未处理的XAML异常,我的应用程序中的UnhandledException处理程序被引发.

UnhandledExceptionEventArgs包含消息

E_RUNTIME_SETVALUE

和ArgumentException类型的内部异常

价值不在预期范围内.

InitialiseComponent()除了抛出任何异常之外,调用堆栈中没有任何东西可以进入/ 重叠.

关于如何进一步调试或任何E_RUNTIME_SETVALUE问题经验的任何想法?

winrt-xaml

5
推荐指数
1
解决办法
646
查看次数

如何递归列出所有文件夹和文件?

如何在python中获取文件夹和文件,包括子目录的文件/文件夹?我需要每个文件/文件夹的绝对路径.

我想重命名所有文件夹和文件.所以我必须先重命名文件夹.

folder
-- file
-- folder1
---- folder1.1
------ file
------ folder1.1.1
-------- file
-- folder2
---- ...
Run Code Online (Sandbox Code Playgroud)

python-2.7

5
推荐指数
1
解决办法
8123
查看次数

如何模拟不在测试范围内的方法?

如何模拟不在测试范围内的方法?

或者:如何模拟一个不直接调用的方法?

在本例中,方法baz
我使用pypi 中的Mock 包

### tests
# ...
def test_method_a(self):
    # how to mock method that is called from bar() ?
    obj = foo.bar()
    self.assertEqual(obj.get('x'), 12345)

### foo
# ...
def bar():
    x = some_module.baz()  # <- how to mock baz() ?
    return x
Run Code Online (Sandbox Code Playgroud)

python mocking python-2.7

5
推荐指数
1
解决办法
2584
查看次数

将文件夹权限分配给“所有应用程序包”组

Win 8 似乎有一个新的用户组“所有应用程序包”。默认情况下,该组似乎对所有文件夹具有读取权限。但是我的要求是在我创建的文件夹上设置一些特定的 ACL。该组目前对我的文件夹没有权限,我编写了一些代码来为“所有应用程序包”添加读取权限。我正在使用 VS 2010,以下是精简后的代码片段。

http://msdn.microsoft.com/en-us/library/cc980032.aspx 中列出的“所有应用程序包”的 SID是 ALL_APP_PACKAGES (S-1-15-2-1)。

但无论我作为受托人以何种方式传递或传递什么值,下面的代码都不起作用。例如,在下面的代码中 SetNamedSecurityInfo() 因 ERROR_INVALID_ACL 失败。但是,如果我使用“管理员”或“所有人”帐户,则它可以工作。

我需要分配的确切权限是“读取和执行”、“列出文件夹内容”和“读取”

#include "stdafx.h"
#include "windows.h"
#include "sddl.h"
#include "Aclapi.h"

int _tmain(int argc, _TCHAR* argv[])
{
TCHAR pszObjName[MAX_PATH] = L"C:\\Program Files\\Common Files\\Test\\";
PACL pOldDACL = NULL, pNewDACL = NULL;
PSECURITY_DESCRIPTOR pSD = NULL;
EXPLICIT_ACCESS ea;
SECURITY_INFORMATION si = DACL_SECURITY_INFORMATION;

// Get a pointer to the existing DACL (Conditionaly).
DWORD dwRes = GetNamedSecurityInfo(pszObjName, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION, NULL, NULL, &pOldDACL, NULL, &pSD);

// Initialize an EXPLICIT_ACCESS structure …
Run Code Online (Sandbox Code Playgroud)

windows desktop-application windows-8

4
推荐指数
1
解决办法
4万
查看次数

字符串到数组?

我有一个字符串"a b" "c" "d ef",我想将其转换为string[]args并拥有一个数组{"a b", "c", "d ef"}.我该如何解析它?

c#

4
推荐指数
1
解决办法
120
查看次数

如何使用TweenMax补间整数变量?

如何在javascript中使用Greensock:TweenMax,TweenLite补间整数变量?

javascript tweenlite tweenmax

4
推荐指数
1
解决办法
1万
查看次数

如何在伪元素中显示缩放的svg?

我想在CSS中的伪元素中显示.svg文件.

.commit-status:before {
    content: url('git.svg');
    margin-right: 7px;
    font-family: 'FontAwesome';
    font-size: 100%;
}
Run Code Online (Sandbox Code Playgroud)

将此.eps文件转换为带有Inkscape的.svg.
这是输出.我认为这是一个有效的转换.

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   version="1.1"
   width="114.8625"
   height="114.8625"
   id="svg3031"
   xml:space="preserve"><metadata
     id="metadata3037"><rdf:RDF><cc:Work
         rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
     id="defs3035" /><g
     transform="matrix(1.25,0,0,-1.25,0,114.8625)"
     id="g3039"><g
       transform="scale(0.1,0.1)"
       id="g3041"><path
         d="M 901.547,500.352 500.355,901.527 c -23.093,23.11 -60.566,23.11 -83.691,0 L 333.363,818.211 439.039,712.535 c 24.559,8.293 52.723,2.727 72.293,-16.847 19.688,-19.696 25.207,-48.102 16.699,-72.75 L 629.887,521.094 c 24.648,8.496 53.066,3.004 72.754,-16.711 27.5,-27.492 27.5,-72.059 0,-99.574 -27.52,-27.516 -72.078,-27.516 -99.61,0 -20.683,20.703 -25.801,51.097 -15.312,76.582 l -95,94.992 0,-249.969 c 6.699,-3.32 13.027,-7.742 18.613,-13.312 27.5,-27.497 27.5,-72.059 0,-99.598 -27.5,-27.488 …
Run Code Online (Sandbox Code Playgroud)

css svg css3 pseudo-element

4
推荐指数
1
解决办法
5602
查看次数

几个MultiDataTriggers仅适用于最后一个

UserControl我有一个类型的DP enum(GroupStyle类型eGroupStyle)和类型bool(IsGrouped)的DP .我需要在所有可能的条件下开始一些故事板.但最后MultiDataTrigger一件作品才有效.我哪里错了?此外,我想知道是否存在一种更简单的方法来考虑这些条件.(检查IsGrouped一次.)

C#:

enum eGroupStyle
{
    GroupStyle1,
    GroupStyle2,
    ???,
    GroupStyleN,
}
Run Code Online (Sandbox Code Playgroud)

XAML:

<MultiDataTrigger>
    <MultiDataTrigger.Conditions>
        <Condition Binding="{Binding GroupStyle}" Value="GroupStyle1"/>
        <Condition Binding="{Binding IsGrouped}" Value="False"/>
    </MultiDataTrigger.Conditions>
    <MultiDataTrigger.EnterActions>
        <BeginStoryboard  Storyboard="{StaticResource Storyboard_TurnToUnselectedStyle1}"/>
    </MultiDataTrigger.EnterActions>
</MultiDataTrigger>
<MultiDataTrigger>
    <MultiDataTrigger.Conditions>
        <Condition Binding="{Binding GroupStyle}" Value="GroupStyle1"/>
        <Condition Binding="{Binding IsGrouped}" Value="True"/>
    </MultiDataTrigger.Conditions>
    <MultiDataTrigger.EnterActions>
        <BeginStoryboard  Storyboard="{StaticResource Storyboard_TurnToSelectedStyle1}"/>
    </MultiDataTrigger.EnterActions>
</MultiDataTrigger>
<MultiDataTrigger>
    <MultiDataTrigger.Conditions>
        <Condition Binding="{Binding GroupStyle}" Value="GroupStyle2"/>
        <Condition Binding="{Binding IsGrouped}" Value="False"/>
    </MultiDataTrigger.Conditions>
    <MultiDataTrigger.EnterActions>
        <BeginStoryboard  Storyboard="{StaticResource Storyboard_TurnToUnselectedStyle2}"/>
    </MultiDataTrigger.EnterActions>
</MultiDataTrigger>
<MultiDataTrigger> …
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml multidatatrigger

3
推荐指数
1
解决办法
1094
查看次数

使span不包裹在具有固定宽度的其他div内

当文本超过父项的100%时,如何使宽度为100%的内容不换行?我四处whitespace: nowrap;走运,没有运气。

问题:span.firstname, span.lastname, span.email当内容的长度大于时,所有的自动换行div.name, div.personal, or div.account_view我希望这3个跨度可以持续很长时间,无论它们的内容是什么(无环绕)。

HTML:

<div class="account_view">
  <div class="personal">

    <div class="picture">
      <img src="example.png" />
      <span>Image caption</span>
    </div>

    <div class="name">
      <span class="first">Firstname</span>
      <span class="last">Lastname</span>
      <span class="email">email@email.com</span>
    </div>

  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS:

div.account_view {
  display: block;
  height: auto;
  width: 700px;
  padding: 40px;
  margin: 0 auto;
  border: 0;
}
div.account_view div.personal {
  margin: 0 auto;
  clear: both;
  overflow: hidden;
  white-space: nowrap;
}
div.account_view div.personal div.picture {
  float: left;
  display: block;
  width: 200px;
  height: …
Run Code Online (Sandbox Code Playgroud)

html css word-wrap

3
推荐指数
1
解决办法
5065
查看次数