小编xie*_*yun的帖子

可以使用python 2.x和python 3.x运行一个python脚本

我有成千上万的服务器(linux),有些只有python 2.x而有些只有python 3.x,我想写一个脚本check.py可以在所有服务器上运行,就像$./ check.py一样,不使用$ python check.py或$ python3 check.py,有没有办法做到这一点?

我的问题是脚本check.py如何找到解释器,无论解释器是python2.x和python3.x

python python-3.x

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

rhel6上的pysvn-1.7.6,错误:不是URL,现有文件或需求规范:

我在RHEL 6上安装了Python 2.7.3,当我尝试安装pysvn-1.7.6时,出现了错误.我该怎么办?

/search/python/pysvn-1.7.6/Import/pycxx-6.2.4/CXX/Python2/Objects.hxx:2912: warning: deprecated conversion from string constant to 'char*'
Compile: pysvn_svnenv.cpp into pysvn_svnenv.o
Compile: pysvn_profile.cpp into pysvn_profile.o
Compile: /search/python/pysvn-1.7.6/Import/pycxx-6.2.4/Src/cxxsupport.cxx into cxxsupport.o
Compile: /search/python/pysvn-1.7.6/Import/pycxx-6.2.4/Src/cxx_extensions.cxx into cxx_extensions.o
Compile: /search/python/pysvn-1.7.6/Import/pycxx-6.2.4/Src/cxxextensions.c into cxxextensions.o
Compile: /search/python/pysvn-1.7.6/Import/pycxx-6.2.4/Src/IndirectPythonInterface.cxx into IndirectPythonInterface.o
Link pysvn/_pysvn_2_7.so
make: *** No rule to make target `egg'.  Stop.
error: Not a URL, existing file, or requirement spec: 'dist/pysvn-1.7.6-py2.7-linux-x86_64.egg'
Run Code Online (Sandbox Code Playgroud)

python pysvn review-board

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

什么= lambda v:v是什么意思?

什么any = lambda v: v意思?似乎v只有v它本身.

class Object(object):                   
    """Common base class supporting automatic kwargs->attributes handling,
    and cloning."""
    attrs = ()

    def __init__(self, *args, **kwargs):
        any = lambda v: v
        for name, type_ in self.attrs:  
            value = kwargs.get(name)    
            if value is not None:       
                setattr(self, name, (type_ or any)(value))
            else:                       
                try:                    
                    getattr(self, name) 
                except AttributeError:  
                    setattr(self, name, None)
Run Code Online (Sandbox Code Playgroud)

python lambda

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

eval() 函数如何改变字典?

eval() 如何改变字典?这是一个例子:创建一个字典 -> print -> eval -> print

>>> a={'a':'a','b':'b'}
>>> print(a)
{'a': 'a', 'b': 'b'}
>>> eval('a == "a"',a)
True
>>> print(a)
{'a': 'a', '__builtins__': {'bytearray': <class 'bytearray'>, 'IndexError': <class 'IndexError'>, 'all': <built-in function all>, 'help': Type help() for interactive help, or help(object) for help about object., 'vars': <built-in function vars>, 'SyntaxError': <class 'SyntaxError'>, 'UnicodeDecodeError': <class 'UnicodeDecodeError'>, 'memoryview': <class 'memoryview'>, 'isinstance': <built-in function isinstance>, '__build_class__': <built-in function __build_class__>, 'copyright': Copyright (c) 2001-2012 Python Software Foundation.
All Rights Reserved.
...
Run Code Online (Sandbox Code Playgroud)

python dictionary eval python-3.x

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

标签 统计

python ×4

python-3.x ×2

dictionary ×1

eval ×1

lambda ×1

pysvn ×1

review-board ×1