小编Kob*_*i K的帖子

ImportError:在windows7 32位中运行pip --version命令时无法导入名称main

我安装了最新的python(2.7.9)捆绑了pip和setuptools for windows 32-bit.我已经尝试重新安装pip,但问题仍然存在.

这是pip --version在Administrator cmd中运行后的错误:

Traceback (most recent call last):
 File "D:\Python\lib\runpy.py", line 162, in _run_module_as_main
  "__main__", fname, loader, pkg_name)
 File "D:\Python\lib\runpy.py", line 72, in _run_code 
  exec code in run_globals
 File "D:\Python\Scripts\pip.exe\__main__.py", line 5, in <module>
ImportError: cannot import name main
Run Code Online (Sandbox Code Playgroud)

python pip importerror

141
推荐指数
6
解决办法
12万
查看次数

在存储过程参数中使用ref cursor vs sys_refcursor

CREATE  OR  REPLACE  PROCEDURE GetEmployeesInDept( c OUT  SYS_REFCURSOR)
Run Code Online (Sandbox Code Playgroud)

我有一个与上述存储过程相关的查询,即在定义游标时我们将其称为sys_refcursor,在某些我们的站点中,我将其视为REF CURSOR,如图所示

创建或替换过程GetEmployeesInDept(c out ref cursor)

请告诉我ref cursor和sys_refcursor有什么区别.

plsql

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

Python在64位vista上获得了os.environ ["ProgramFiles"]的错误值

Vista64机器上的Python 2.4.3.

以下2个变量位于环境中:

ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
Run Code Online (Sandbox Code Playgroud)

但是当我运行以下内容时

import os
print os.environ["ProgramFiles"]
print os.environ["ProgramFiles(x86)"]
Run Code Online (Sandbox Code Playgroud)

我明白了:

C:\Program Files (x86)
C:\Program Files (x86)
Run Code Online (Sandbox Code Playgroud)

任何想法如何才能获得"ProgramFiles"的正确值?

python windows 64-bit

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

pytest测试类调用类方法,类型错误只需2个参数(给定1个)

我有一个测试类来测试我的方法但是我有一些传递self的问题,它们都在class和test类中.

我的方法:

def get_all_links(self):
    """return all the links inside an html

    :return: list of links from an html page
    :rtype: list
    """
    return self.html.find_all('a')
Run Code Online (Sandbox Code Playgroud)

我的测试用例:

    @parameterized.expand(["http://www.google.com", "http://www.walla.com"])
    def test_get_all_links_known_links(self, known_link):
        """check get_all_links with a known link list

        :param known_link: lick to find
        :type known_link: str
        """
        html = Parser(open(os.path.normpath(os.path.join(self.root, "test.html"))))

        self.assertTrue(any([known_link in str(l) for l in html.get_all_links()]))
Run Code Online (Sandbox Code Playgroud)

错误:

E TypeError: test_get_all_links_known_links() takes exactly 2 arguments (1 given)

/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py:329: TypeError
...
Run Code Online (Sandbox Code Playgroud)

python unit-testing pytest

7
推荐指数
1
解决办法
1457
查看次数

python JIRA 与代理的连接

我正在尝试使用代理通过 python-jira 连接:

server = {"server": "https://ip:port/jira",
          'proxies': {"http": "http://ip:port", "https": "http://ip:port"},
          'verify': False,
          'stream': True}

cls.jira_object = JIRA(options=server,
                       basic_auth=(user, password),
                       validate=True)
Run Code Online (Sandbox Code Playgroud)

回溯错误:

tests\jira_test\ticket_test.py:52: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
build\bdist.win-amd64\egg\jira\client.py:217: in __init__
    ???
build\bdist.win-amd64\egg\jira\client.py:1841: in session
    ???
build\bdist.win-amd64\egg\jira\utils.py:78: in json_loads
    ???
_ _ _ _ …
Run Code Online (Sandbox Code Playgroud)

python jira basic-authentication python-jira

6
推荐指数
1
解决办法
7702
查看次数

Python @property设计

关于python @property的设计问题,我遇到了这两个选项:

选项1:

class ThisIsMyClass(object):

    @property
    def ClassAttr(self):
        ...

    @ClassAttr.setter
    def ClassAttr(self, value):
        ...
Run Code Online (Sandbox Code Playgroud)

选项2:

class ThisIsMyClass(object):

    def set_ClassAttr(self, value):
        ...

    def get_ClassAttr(self):
        ...

    myProperty = property(get_ClassAttr, set_ClassAttr)
Run Code Online (Sandbox Code Playgroud)

题:

我想知道使用这两个选项是否有任何区别?

如果是这样,它如何影响我的代码?

python properties

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

在setup.py pytest.main中使用py.test --cov

我正在开发一些测试包.

与CMD合作:

py.test --cov my_pkg
Run Code Online (Sandbox Code Playgroud)

我用covarage得到了结果:

--------------- coverage: platform win32, python 2.7.9-final-0 ----------------
Name                            Stmts   Miss  Cover
---------------------------------------------------
my_pkg\__init__       8      0   100%
my_pkg\general        2      0   100%
---------------------------------------------------
TOTAL                              10      0   100%
Run Code Online (Sandbox Code Playgroud)

失败:

当试图将其集成到内部pytest.main()并运行时:

python setup.py test

以下内容:

============================= test session starts =============================
platform win32 -- Python 2.7.9 -- py-1.4.26 -- pytest-2.7.0
rootdir: C:\Users\kobi.kalif\Projects\automation_utilities, inifile:
plugins: cov, xdist

ERROR: file not found: --cov my_pkg
Run Code Online (Sandbox Code Playgroud)

相关守则:

class PyTest(test_command):
    """class py.test for the testing

    """
    user_options = []

    def __init__(self, dist, …
Run Code Online (Sandbox Code Playgroud)

python pytest test-coverage

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

Python和JIRA从特定问题中获取字段

我正在尝试从特定问题获取所有字段和值我的代码:

authenticated_jira = JIRA(options={'server': self.jira_server}, basic_auth=(self.jira_username, self.jira_password))
issue = authenticated_jira.issue(self.id) 
print issue.fields()
Run Code Online (Sandbox Code Playgroud)

而不是返回它返回的字段列表:

<jira.resources.PropertyHolder object at 0x108431390>
Run Code Online (Sandbox Code Playgroud)

python python-jira jira-rest-api

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

python:如何将列表转换为 c_byte 数组

我在dll中有ac函数。

它有一个像这样的界面int dcm(char inmsg[], int length);

现在我有一个像这样的列表(会员数量有时超过1000)

a = [0x41,0x00,0x00,0xC8,0x08,0x01,0x03,0x00,0x00,0x02,0x10,0x00,0x66,0x62,0x05,0x00,0x06,0x00,0x57,0x02,0x01,0xBF,0xFF,0x00,0xBF,0x9A,0x00,0x05,0x80,0x10,0x32,0x00,0x07,0x1F,0x00,0x00,0x05,0x00,0xD1,0x01,0x01,0xBF,0x04,0x00,0x03,0xBF,0x04,0x00,0x21,0x64,0x00,0x00,0x0A,0xBF,0xFF,0x00,0xBF,0xFF,0x00,0xBF,0xFF,0x00,0xBF,0xF3,0x00]
Run Code Online (Sandbox Code Playgroud)

我想将列表转换为c_byte数组并将其作为函数的第一个参数传递dcm

如何将其转换为 c_byte 数组?

python arrays list

2
推荐指数
1
解决办法
2059
查看次数

在python中合并两个相同的值

例如,我有这个数字/id 列表:

[1001, 1002, 1002, 1003, 1004]

我如何合并或使 1002 只有一个?所以它会是这样的:

[1001, 1002,1003, 1004]

我知道这是非常基本的,我一直在 Google 中寻找解决方案有一段时间了,我所看到的只是如何合并dicts,这不是我需要的。我只需要合并这些相同的值。

python

2
推荐指数
1
解决办法
150
查看次数