2013年6月5日
摘要: 1 <table border="1px"> //创建一个表格 有边框 2 <tr> //创建一行 3 <td></td> //行内的内容 4 <td></td> //行内的内容 5 6 </tr> 7 <tr> //创建一行 8 <td></td> //行内的内容 9 <td></td> //同上10 </tr>11 12 </table>border-collapse:collapse; //表格的边框是 阅读全文
posted @ 2013-06-05 16:29 Linuxroot 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 字体风格:font-size:12px; //字体大小color:red; //字体颜色front-family:Garamond; //字体其它:background-color:brown; //背景颜色text-align:center; //文本的位置 左 中 右<strong></strong> //加粗字体<em></em> //倾斜字体 阅读全文
posted @ 2013-06-05 16:21 Linuxroot 阅读(89) 评论(0) 推荐(0) 编辑
  2013年5月30日
摘要: 创建一个类 1 class Person{ 2 //类的属性 相当于变量 3 public $firstname; 4 public $lastname; 5 public $age; 6 7 //construct方法 类当中的方法相当于php里的函数 8 public function __construct(){ 9 //对于不同的类 我们可以有不同的属性10 $this->firstname = $firstname;11 $this->lastname = $lastname;12 ... 阅读全文
posted @ 2013-05-30 13:23 Linuxroot 阅读(156) 评论(0) 推荐(0) 编辑
  2012年11月20日
摘要: 函数和文件 1 from sys import argv 2 3 script, input_file = argv 4 5 def print_all(f): 6 print f.read() 7 8 def rewind(f): 9 f.seek(0)10 11 def print_a_line(line_count, f):12 print line_count, f.readline()13 14 current_file = open(input_file)15 16 print "First let's print the whole file:\n". 阅读全文
posted @ 2012-11-20 10:24 Linuxroot 阅读(233) 评论(0) 推荐(0) 编辑
摘要: 每次用vim 都要:set nu 挺麻烦的 干脆就直接设置配置文件了 vi ~/.vimrc 添加set nu 就不用那么麻烦了读取文件 1 # linux.txt 文本里面有三行字 2 from sys import argv 3 4 script, filename = argv 5 #打开文件 6 txt = open(filename) 7 8 print "Here's your file %r: " % filename 9 print txt.read() #输出文本内容10 #raw_input打开11 print "Type the fi 阅读全文
posted @ 2012-11-20 09:30 Linuxroot 阅读(141) 评论(0) 推荐(0) 编辑
  2012年11月18日
摘要: 用户输入 1 print "How old are you?", 2 age = raw_input() 3 print "How tall are you?", 4 height = raw_input() 5 print "How much do you weight?", 6 weight = raw_input() 7 8 print "so you're %r old, %r tall and %r heavy." % (age,height,weight) 9 10 #如果把%r 换成 %d 竟 阅读全文
posted @ 2012-11-18 12:16 Linuxroot 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 第一个程序 输出hello world1 #这是一个注释 2 print "Hello world!"数字和数学运算 + - * / % > <1 #输入 'linuxroot 19'2 print "linuxroot", 10 + 18 / 23 4 #输出 False 19 比15大 5 print 10 + 9 < 10 + 56 7 #模运算 取余数 结果是 18 print 5 % 2变量 1 # 下面定义了一些变量 2 3 my_age = 19 4 5 my_name = 'linuxroot&# 阅读全文
posted @ 2012-11-18 11:21 Linuxroot 阅读(176) 评论(0) 推荐(0) 编辑
  2012年11月10日
摘要: 1 def break_words(stuff): 2 """This function will break up words for us.""" 3 words = stuff.split(' ') 4 return words 5 6 def sort_words(words): 7 """Sorts the words.""" 8 return sorted(words) 9 10 def print_first_word(words):11 &qu 阅读全文
posted @ 2012-11-10 08:55 Linuxroot 阅读(281) 评论(0) 推荐(0) 编辑
  2012年11月4日
摘要: 1 from sys import argv 2 3 script, input_file = argv 4 5 def print_all(f): 6 print f.read() 7 8 def rewind(f): 9 f.seek(0)10 11 def print_a_line(line_count, f):12 print line_count, f.readline()13 14 current_file = open(input_file)15 16 print "First let's print the whole file:\n"17 18.. 阅读全文
posted @ 2012-11-04 11:39 Linuxroot 阅读(273) 评论(0) 推荐(0) 编辑
摘要: 函数 print_two 的问题是:它并不是创建函数最简单的方法。在 Python 函数中我们可以跳过整个参数解包的过程,直接使用 () 里边的名称作为变量名。这就是 print_two_again 实现的功能。接下来的例子是 print_one ,它向你演示了函数如何接受单个参数。最后一个例子是 print_none ,它向你演示了函数可以不接收任何参数。 1 # this one is like your scripts with argv 2 def print_two(*args): 3 arg1, arg2 = args 4 print "arg1: %r, arg2... 阅读全文
posted @ 2012-11-04 11:26 Linuxroot 阅读(176) 评论(0) 推荐(0) 编辑