zoukankan      html  css  js  c++  java
  • anyway,gnuradio需要学习python,so let us start

       

    不得不说python有几个网站:

    GNURADIO上说的网站:http://docs.python.org/tutorial/introduction.html

    还有自己搜索到:http://diveintopython.org/

    我自己的硬件环境:

    CPU:I3 530

    内存:4G

    OS:Ubuntu 10.4

    第一,安装,在命令行下打入python,发现没按照,输入

    sudo apt-get install python

    第二,按照完后,打开 Invoking the Interpreter

    教程上写的:

    The Python interpreter is usually installed as /usr/local/bin/python on those machines where it is available; putting /usr/local/bin in your Unix shell’s search path makes it possible to start it by typing the command

    python
    
    to the shell. Since the choice of the directory where the interpreter lives is an installation option, other places are possible; check with your local Python guru or system administrator. (E.g., /usr/local/python is a popular alternative location.)
     
     
    接下来可以进行编程。
     
     
    可以直接启动python进去输入脚本,其实python说白了就是脚本语言类似,和MATLAB语言差不多,不用编译直接用那种。
     
    下面继续学习,我看《dive into python》,按照里边输入了第一个例子,
    源代码:
     
    """odbchelper.py sample script
    
    This program is part of "Dive Into Python", a free Python book for
    experienced programmers.  Visit http://diveintopython.org/ for the
    latest version.
    All this stuff at the top of the script is just optional metadata;
    the real code starts on the "def buildConnectionString" line
    """
    __author__ = "Mark Pilgrim (mark@diveintopython.org)"
    __version__ = "$Revision: 1.2 $"
    __date__ = "$Date: 2004/05/05 21:57:19 $"
    __copyright__ = "Copyright (c) 2001 Mark Pilgrim"
    __license__ = "Python"
    def buildConnectionString(params):
     """Build a connection string from a dictionary
     
     Returns string.
     """
     return ";".join(["%s=%s" % (k, v) for k, v in params.items()])
    if __name__ == "__main__":
     myParams = {"server":"mpilgrim", \
        "database":"master", \
        "uid":"sa", \
        "pwd":"secret"
        }
     print buildConnectionString(myParams)
     
    
    结束后,chmod +x odbchelper.py 
    
    运行发现错误如下:
    ./odbchelper.py: line 11: __author__: command not found
    ./odbchelper.py: line 12: __version__: command not found
    ./odbchelper.py: line 13: __date__: command not found
    ./odbchelper.py: line 14: __copyright__: command not found
    ./odbchelper.py: line 15: __license__: command not found
    ./odbchelper.py: line 17: syntax error near unexpected token `('
    ./odbchelper.py: line 17: `def buildConnectionString(params):'
     
    然后我上网查了一下,发现是白痴问题,我没把Interpreter的路径写到文件中
    在文件第一行加上:#! /usr/bin/python
    问题解决,出现:server=mpilgrim;uid=sa;database=master;pwd=secret
    和网上的教程一样
     
  • 相关阅读:
    成功,离你只有一步之遥
    多灾多难!危机下给企业家们的十大贴心忠告
    《赢道:成功创业者的28条戒律》 简介:
    面对大面积失业潮,普通人有无必要创业?
    赢在行动《越狱》给创业者的启示
    如何优选创业项目、产品和服务
    你是高执行力人才吗?
    创业新闻] 2009年创业者必读的十一本书(转)
    赢在2009 创业者需练好六脉神剑(转)
    相当受用!10个从实质上迅速提升经理人生活的方法
  • 原文地址:https://www.cnblogs.com/nickchan/p/3104551.html
Copyright © 2011-2022 走看看