小编pri*_*odi的帖子

在python中如何从字符串或列表中删除此\n

这是我的主要字符串

"action","employee_id","name"
"absent","pritesh",2010/09/15 00:00:00
Run Code Online (Sandbox Code Playgroud)

所以在名称coolumn之后它会转到新行但是在这里我追加到列表中添加了一个新的行字符,并使其像这样

DATA_LIST*****['"action","employee_id","name"\n"absent","pritesh",2010/09/15 00:00:00\n']

在这里它附加了新的线条字符缺席,但实际上它是一个新的线条,但它附加我希望使它像

DATA_LIST*****['"action","employee_id","name","absent","pritesh",2010/09/15 00:00:00']

python string

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

AttributeError: 对象没有属性“_type_equality_funcs”

我的程序的 Unittest 模块实现出现以下错误

File "/usr/lib/python2.7/unittest/case.py", line 493, in _getAssertEqualityFunc
    asserter = self._type_equality_funcs.get(type(first))
AttributeError: 'Utility' object has no attribute '_type_equality_funcs'  
Run Code Online (Sandbox Code Playgroud)

当我尝试创建一个通用类并尝试通过通用类实用程序测试函数执行时遇到错误,但使用正常的 Unittest 类实现没有错误。

下面是程序的详细说明,它执行没有任何错误

class BaseTestCase(unittest.TestCase):

    def __init__(self, methodName='runTest', param=None):
        super(BaseTestCase, self).__init__(methodName)
        self.param = param

    @staticmethod
    def parametrize(testcase_klass, param=None):

        testloader = unittest.TestLoader()
        testnames = testloader.getTestCaseNames(testcase_klass)
        suite = unittest.TestSuite()
        for name in testnames:
            suite.addTest(testcase_klass(name, param=param))
        return suite
Run Code Online (Sandbox Code Playgroud)

现在我正在继承 BaseTestCase 类并调用测试用例..

     class salesgrowth_DevInt(BaseTestCase):
          def setUp(self):
                print "constructor"
                pwd = os.getcwd()

     def test4_refactoring(self,log):
             if (STATUS.lower() == "completed" or STATUS == "Actor : SUCCESS"):`enter code …
Run Code Online (Sandbox Code Playgroud)

python python-2.7

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

标签 统计

python ×2

python-2.7 ×1

string ×1