`
文章列表
C05 Standard Types 1. String   print <<STRING1,<<STRING2 Concat STRING1 enate STRING2 produces: Concat enate     2. Range    a = 1..3 #a = 1,2,3 a = 1...3 # a = 1,2   (1..10) === 5 ! true (1..10) === 15 ! false (1..10) === 3.14159 ! true ('a'..'j') === 'c' ! true ('a'.. ...
不应该算是新学Ruby吧,应该算是复习。Rails也用过一些,不过之前没有这样做过笔记。我曾经写过一个帖子,讨论关于Perl,Python和Ruby的,写得还比价客观。这里我只想表达一个观点,如果从语法和概念上说,我更喜欢Ruby。这不是我一个人的观点,至少我认识几个Python的小牛也认为Python的语法不是很好“玩”。譬如,那种缩进表示的Block,譬如你要用全局函数open,len。虽然我更prefer{}来表示一个block,不过坦白说Ruby用end我还是能接受的(我就纳闷了,明明一个end就很OK,为什么Delphi和Basic要用Begin和End呢?)。而那种File.new, ...
美国人五星级句子 1. After you. 你先请。这是一句很常用的客套话,在进/出门,上车得场合你都可以表现一下。 2. I just couldn’t help it. 我就是忍不住。想想看,这样一个漂亮的句子可用于多少个场合?下面是随意举的一个例子: I was deeply moved by the film and I cried and cried. I just couldn’t help it. 3. Don’t take it to heart. 别往心里去,别为此而忧虑伤神。生活实例: This test isn’t that important. Don’t take i ...
老外最常说的二十个钻石级句子1.After you. 你先请 2.Don’t take it to heart. 别往心里去,别因此而费神 3.We’d better be off。我们该走了 4.Let’s face it。面对现实把(当你不愿意躲避困难时,就用它吧) 5.Let’s get started。咱们开始干 6.I’m really dead。我真的要累死了(有的时候当你的课业负担太重的时候,对你的英语老师说吧) 7.I’ve done my best。我已经尽力了 8.Is that so?真是那样的吗? 9.Don’t play games with me。别跟我耍花招(某人说 ...
我在自己的MacOS中,使用bash作为自己的默认Shell(在单位中使用Solaris,一般用tcsh)。 a.x > out.txt #将标准输出重定向到out.txt a.x 1> out.txt #同上 a.x 2> out.txt #将标准错误重定向到out.txt a.x >& out.txt #将标准输出和标准错误都重定向到out.txt
Standard Library Library Name Usage Sample os 提供一些类似于Shell的操作 >>> import os >>> os.system('time 0:02') 0 >>> os.getcwd() # Return the current working directory 'C:\\Python30' >>> os.chdir('/server/accesslogs')   shutil 文件和目录管理 ...
Class 1. Namespace and Scope     def scope_test(): def do_local(): spam = "local spam" def do_nonlocal(): nonlocal spam spam = "nonlocal spam" def do_global(): global spam spam = "global spam" spam = "test spa ...
Module 1. 基础 #fib.py def fib2(n): rst = [] a, b = 0 ,1 while b < n: rst.append(b) a, b = b, a+b return rst if __name__ == '__main__': import sys print(fib2(int(sys.argv[1])))   >>> import fib >>> fib.fib2(2000) [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 2 ...
11 创建视图 CREATE VIEW is_student AS SELECT Sno, Sname, Sage from student WHERE Sdept='IS'; create view S_G(Sno, Gavg) AS select Sno, AVG(Grade) from SC GROUP by Sno;     12 查询视图 select * from S_G where Gavg>=86;     13 更新视图 update is_student SET Sname='刘琛' where Sno='95002';   14 增加用户权限 grant select ...
An Informal Introduction to Python   1. Number   >>> -7//3-3>>> 7//-3-3  _ 表示最后的计算结果   2.  str   str是immutable的   word = "helloA" word[1] # "e" word[-1] #"A" word[1:3] #"el" word[3:1] #"" word[1:] #"elloA" word[100] ...
    7.4 嵌套查询 select Sno, Sname, Sdept from student where Sdept=(select Sdept from Student where Sname='刘晨'); select Sno, Sname from student where Sno in (select Sno from sc where Cno=(select Cno from course where Cname='信息系统' ));   上面的第二个例子和下面这个查询语句是等价的: select Student.Sno, Sname from student, sc, ...
 最近在学习数据库理论,顺便把SQL学习一下,下面列出常用的SQL命令 (全部在MySQL上测试通过)。   1.  创建表  CREATE TABLE Student (Sno CHAR(5) NOT NULL UNIQUE, Sname CHAR(20), Ssex CHAR(2), Sage INT, Sdept CHAR(15)); CREATE TABLE course(Cno CHAR(5) NOT NULL UNIQUE, Cname CHAR(30), Cpno CHAR(5), Ccredit SMALLINT); CREATE TABLE SC(Sno char(5) NOT ...
这本书是我在www.iphoneside.com上看到的,Amazon上给出了4星半。于是我把它下载回来看,现在还差最后一张内容和AppendixA没看。总体感觉写的非常好。         这是一本入门书。作为一本入门书,我认为像<C++ Primer>和<Thinking in Java>这样的很不错,可惜有些大,最值得称道的是<Python Tutorial>这样的。把基本的概念告诉你,让我们有个扎实的基础。然后再讲解一些常用库,因为写过程序的都知道,我们不是活在一个真空的世界,无论写什么程序,我们都需要库甚至框架的支持。<Learn Object ...
第四章  变量   1.  变量的范围 感觉这个和Java/C++的差别比较大。   (1) 首先就是没有block scope,譬如: function test(o) { var i = 0; // i is defined throughout function if (typeof o == "object") { var j = 0; // j is defined everywhere, not just block for(var k=0; ...
Javascript -- 一种分布最广的语言   在人类的世界,如果你只是把语言作为一种交流工具,那么无疑你应该学好英语。因为几乎在世界的任何角落,英文都可以让你买到你想买的食物,去你想去的地方,交到你想认识的朋友。那么 ...
Global site tag (gtag.js) - Google Analytics