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
    和网上的教程一样
     
  • 相关阅读:
    观《phonegap第三季 angularjs+ionic视频教程 实时发布》学习笔记(一)
    npm的本地模式与全局模式
    Nodejs的Express完成安装指导
    app安装位置声明
    vs2005水晶报表无法运行在X64机器上
    SQL递归查询(with cte as)
    System.IO.File.Create 不会自动释放,一定要Dispose
    imail 删除历史邮件命令
    Deferred解决JS同步问题
    HttpContext.Current.Cache使用文件依赖问题
  • 原文地址:https://www.cnblogs.com/nickchan/p/3104551.html
Copyright © 2011-2022 走看看