09 2019 档案
摘要:import 后面跟的是(module)包,是python本来写好的,或者是别人写好的,你安装到了本地的 #引入urllib2这个包 import urllib2 使用urllib2这个包里的urlopen方法 urllib2.urlopen 比如说你做了一个实现了功能A的包,这个包在python中
阅读全文
摘要:这样写对的 L = ['Adam', 'Lisa', 'Bart']L.insert(1,'Paul')print (L) 这样写为什么打印结果是None L = ['Adam', 'Lisa', 'Bart']print (L.insert(1,'Paul'))
阅读全文
摘要:def get_data(self, beginDay,endDay): url = self.domain + '/basMC/console/commonAnalysisV3/main.do' req_data = 'method=getCommonSimpleLine&beginDay=' +
阅读全文
摘要:\n 表示换行\t 表示一个制表符\\ 表示 \ 字符本身 print ('Bob said \"I\'m OK\"') 任务 请将下面两行内容用Python的字符串表示并打印出来: Python was started in 1989 by "Guido". Python is free and
阅读全文
摘要:变量不仅可以是数字,还可以是任意数据类型,在Python程序中,变量是用一个变量名表示,变量名必须是大小写英文、数字和下划线(_)的组合,且不能用数字开头 a='ABC'a='XYZ'b=aprint (a) 打印结果为XYZ a='ABC'a='XYZ'b=aprint (b) 打印结果为XYZ
阅读全文
摘要:引号内,空格就表示空格,引号外,逗号表示空格 print('100+200 =',100 + 200) 100+200 = 300 print('hello','world') hello world print('hello,world') hello,world
阅读全文
摘要:缩进相当于其他语言的括号,括号中的语句才是一起执行的 这一个函数的功能应该是计算平均分 所以d这个dict应该是作为参数传进来的,而不是写到函数内部 正确的写法 d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }def f(d={}): su
阅读全文
摘要:第一种,for循环和print是同级的,只有当for循环结束了才会print d=[]for i in range(1, 101): d.append(i)print d[6::7] 第二种,也就是print在for循环里面,所以每循环一次就打印一次 d=[]for i in range(1, 10
阅读全文
摘要:数学函数y = f(x)y -> 函数值f(x) -> 计算公式,如x*x程序函数def f(x): r = x*x return rdef f(x) -> f(x)return r 返回一个值 -> yr = x*x -> 函数表达式
阅读全文