摘要:
L = ['Bart', 'Lisa', 'Adam'] for i in L: print("这是for循环的" + "输出 hello:" + i.upper()) i = 0 while i < len(L): print("这是while 循环的输出 hello:" + L[i]) i = i + 1 阅读全文
摘要:
# 交互式编码 # Python3 的字符串使用Unicode,但最常用的编码就是utf-8,下面给出交互式修改编码的方法 s = 'Python-中文' print(s) b = s.encode('utf-8') print(b) print(b.decode('utf-8')) 阅读全文
摘要:
# 格式化 print("hello ,%s you have $%d" % ("Jack", 10000)) print("%0.4f" % 3.1415926) print("北戴河房价环比上涨:%0.2f %%" % 2.87) score_1 = 72 score_2 = 85 r = (score_2 - score_1) / score_1 print("小明本学期同比上学期成绩提... 阅读全文
摘要:
在每次生成伪随机数的时候,函数都会使用一个不同的种子,因此会输出不同的结果。可以通过函数set.seed()显式的指定这个种子,让结果得以重现(reproducibe) 阅读全文
摘要:
从iris数据集中随机抽取一个大小为20的样本 参数说明: 第一个参数:要从中抽取元素的数据集 第二个参数:要抽取的元素数量 第三个参数:表示抽样有无放回 1、无放回(replace=FALSE) 2、有放回(replace=TRUE) 阅读全文