摘要: from sys import argvscript, input_file = argvdef print_all(f): print f.read() def rewind(f): f.seek(0)def print_a_line(line_count, f): pri... 阅读全文
posted @ 2014-10-24 09:46 林中细雨 阅读(177) 评论(0) 推荐(0) 编辑
摘要: def cheese_and_crackers(cheese_count, boxes_of_crackers): print "You have %d cheeses!" % cheese_count print "You have %d boxes of crackers!" % boxes... 阅读全文
posted @ 2014-10-24 09:41 林中细雨 阅读(161) 评论(0) 推荐(0) 编辑
摘要: # this one is like your scripts with argvdef print_two(*args):arg1, arg2 = args print "arg1: %r, arg2: %r" % (arg1, arg2)# ok, that *args is actually ... 阅读全文
posted @ 2014-10-23 21:32 林中细雨 阅读(144) 评论(0) 推荐(0) 编辑
摘要: from sys import argv from os.path import existsscript, from_file, to_file = argvprint "Copying from %s to %s" % (from_file, to_file)# we could do thes... 阅读全文
posted @ 2014-10-23 21:27 林中细雨 阅读(150) 评论(0) 推荐(0) 编辑
摘要: from sys import argvscript, filename = argvprint "We're going to erase %r." % filename print "If you don't want that, hit CTRL-C (^C)." print "If you ... 阅读全文
posted @ 2014-10-23 21:23 林中细雨 阅读(130) 评论(0) 推荐(0) 编辑
摘要: Defination:累积分布函数:The cumulative distribution function (CDF) does just that. The CDF at point x tells us whatfraction of events has occurred “to the l... 阅读全文
posted @ 2014-10-23 21:01 林中细雨 阅读(420) 评论(0) 推荐(0) 编辑
摘要: from sys import argvscript, filename = argvtxt = open(filename)print "Here's your file %r:" % filename print txt.read()print "Type the filename again:... 阅读全文
posted @ 2014-10-23 12:09 林中细雨 阅读(135) 评论(0) 推荐(0) 编辑
摘要: from sys import argvscript, user_name = argvprompt = '> 'print "Hi %s, I'm the %s script." % (user_name, script)print "I'd like to ask you a few quest... 阅读全文
posted @ 2014-10-23 12:05 林中细雨 阅读(163) 评论(0) 推荐(0) 编辑
摘要: from sys import argvscript, first, second, third = argvprint "The script is called:", scriptprint "Your first variable is:", firstprint "Your second v... 阅读全文
posted @ 2014-10-23 11:57 林中细雨 阅读(228) 评论(0) 推荐(0) 编辑
摘要: age = raw_input("How old are you? ")height = raw_input("How tall are you? ")weight = raw_input("How much do you weigh? ")print "So, you're %r old, %r ... 阅读全文
posted @ 2014-10-23 11:37 林中细雨 阅读(131) 评论(0) 推荐(0) 编辑