随笔分类 - Python
摘要:最近领导给了一个任务,从单位的数据库里面导出所有的数据,存到本地excel表格。我就想,这不挺简单的么,给我数据库的密码账户,几条语句搞定。结果让人大失所望,单位数据库只能通过后台管理系统查看,平台压根不提供批量导出功能,至于数据库直接访问什么的,更是想都别想,大领导不给批。所以,只能采取笨办法了,...
阅读全文
摘要:这里有一段python代码,可用于操控ardrone 2.0。实验室曾经借鉴用过,并添加了部分功能。如今复习一下,顺便理理python的相关知识点。#!/usr/bin/env python# A basic drone controller class for the tutorial "Up a...
阅读全文
摘要:1.Python passes everything the same way, but calling it "by value" or "by reference" will not clear everything up, since Python's semantics are different than the languages for which those terms usually apply. If I was to describe it, I would say that all passing was by value
阅读全文
摘要:Never mix tabs and spaces.The most popular way of indenting Python is with spaces only. The second-most popular way is with tabs only. Code indented with a mixture of tabs and spaces should be converted to using spaces exclusively. When invoking the Python command line interpreter with the-toption,
阅读全文
摘要:NumPy has the same functionality as Matlab in terms of arrays (maybe a little more) but there are some syntax differences in creating and indexing arrays that confused me at first when switching from Matlab to NumPy.There is amore comprehensive tutorialon NumPy, here I’m just trying to work out some
阅读全文
摘要:刚学用Python的时候,特别是看一些库的源码时,经常会看到func(*args, **kwargs)这样的函数定义,这个*和**让人有点费解。其实只要把函数参数定义搞清楚了,就不难理解了。先说说函数定义,我们都知道,下面的代码定义了一个函数funcAdef funcA(): pass显然,函数funcA没有参数(同时啥也不干:D)。下面这个函数funcB就有两个参数了,def funcB(a, b): print a print b调用的时候,我们需要使用函数名,加上圆括号扩起来的参数列表,比如 funcB(100, 99),执行结果是:10099很明显,参数的顺序和个数要和函数定义中一致,
阅读全文
摘要:1.全局变量python中对全局变量的处理有些技巧性。一般而言,若要在某一个函数(或者局部代码段)“访问”(或者说read)全局变量,是不需要事先声明global的比如下列代码1 a = 12 3 def func():4 b = a5 print b6 7 if __name__ == '__main__':8 func()将输出4。func中的a为全局变量。如果,我们要改变全局变量,必须声明global。看下面的代码a = 1def func(): global a a = 4if __name__ == '__main__': func() ...
阅读全文

浙公网安备 33010602011771号