TypeError: 'str' object is not callable

xiaoyu_2015 发布于 2016/09/12 11:35
阅读 157
收藏 0

centos 6.5X64 python2.6.6

代码如下:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os

un_tar = ["hbase-1.2.2-bin.tar.gz","spark-2.0.0-bin-hadoop2.6.tgz","apache-hive-2.1.0-bin.tar.gz",
          "zookeeper-3.4.9.tar.gz","hadoop-2.6.4.tar.gz","scala-2.11.8.tgz"]
install_home = '/usr/ADH/'
java_install_home = '/usr/java/'
java_file = "jdk-8u101-linux-x64.tar.gz"

local_dir = "/root/"

for f in un_tar:
    print "tar -zxf {0} -C {1}".format(local_dir + f, install_home)
    os.system("tar -zxf %s -C %s"(local_dir + f, install_home))



执行时报错如下:

[root@adh1 ~]# ./1.py
tar -zxf /root/hbase-1.2.2-bin.tar.gz -C /usr/ADH/
Traceback (most recent call last):
  File "./1.py", line 16, in <module>
    os.system("tar -zxf %s -C %s"(local_dir + f, install_home))
TypeError: 'str' object is not callable


自己也有搜了下,都是在说自己定义的变量名和python的底层函数名冲突的。但我这个可以确定是没有名称冲突的啊,用print打印出来发现linux命令也没错啊,这个要怎么破啊?


加载中
1
NickWilde
NickWilde
少打了一个%
1
刘大神
刘大神
un_tar是元组,local_dir是str 这类型能一起连接么?
返回顶部
顶部