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
    和网上的教程一样
     
  • 相关阅读:
    iOS——归档对象的创建,数据写入与读取
    iOS——plist的创建,数据写入与读取
    SQL SERVER 2005快捷键
    图片放大源码
    验证url 地址是否是图片
    JS三大经典变量命名法
    载入锁频
    SQL Server 查询分析器键盘快捷方式
    关于ajax get方式请求 url地址参数怎么变成空了的问题
    SQL计算表的列数
  • 原文地址:https://www.cnblogs.com/nickchan/p/3104551.html
Copyright © 2011-2022 走看看