06 2013 档案
摘要: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,
阅读全文
摘要:强制类型转换的一般形式为:(类型名)(表达式)如:(int)a。这是C语言使用的形式,C++把它保留了下来,以利于兼容。C++还增加了以下形式:类型名(表达式)如:int(a)。这种形式类似于函数调用。
阅读全文
摘要:这些数据类型是 C99 中定义的,具体定义在:/usr/include/stdint.h ISO C99: 7.18 Integer types <stdint.h> 1 /* There is some amount of overlap with <sys/types.h> as known by inet code */ 2 #ifndef __int8_t_defined 3 # define __int8_t_defined 4 typedef signed char int8_t; 5 typedef short int in...
阅读全文
摘要:printf("\033[47;31mhello world\033[5m");47是字背景颜色, 31是字体的颜色, hello world是字符串. 后面的\033[5m是控制码.颜色代码:QUOTE:字背景颜色范围: 40--49 字颜色: 30--39 40: 黑 30: 黑 41: 红 31: 红 42: 绿 32: 绿 43: 黄 33: 黄 44: 蓝 34: 蓝 45: 紫 35: 紫 4...
阅读全文
摘要:from the documentation (hereis a page that shows it though). To use this version, import rq like this:from scipy.linalg import rqAlternatively, you can use the more commonQR factorizationand with some modifications write your own RQ function.from scipy.linalg import qrdef rq(A): Q,R = qr(flipud(A)..
阅读全文
摘要:Solution 1:Connect to the internet and run this command below, to fix the errorsudo apt-get install --reinstall ttf-mscorefonts-installer This will reinstall the package, and download the data files needed to configure the package. Wait for some times to finish downloading. The download size is appr
阅读全文
摘要: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很明显,参数的顺序和个数要和函数定义中一致,
阅读全文
摘要:One of the questions an instrutor dreads most from a mathematically unsophisticated audience is, "What exactly is degrees of freedom?" It's not that there's no answer. The mathematical answer is a single phrase, "The rank of a quadratic form." The problem is translating t
阅读全文
摘要:1.在类里声明的类的静态成员只是起到一个说明作用,并不会分配成员的变量空间.必须另外在类外面进行声明.例如,intBoy::m=0;即使不进行初赋值,也要有这样一个定义语句:intBoy:m;因为只有这样,编译程序才分配了变量的空间.否则,便会在链接的时候,出现:undefinedreferenceto`Boy::m'这样的错误.2.尽管成员是在类的定义体之外定义的,但成员定义就好像它们是在类的作用域中一样。回忆一下,出现在类的定义体之外的成员定义必须指明成员出现在哪个类中:doubleSales_item::avg_price()const{if(units_sold)returnr
阅读全文