摘要: 描述 complex() 函数用于创建一个值为 real + imag * j 的复数或者转化一个字符串或数为复数。如果第一个参数为字符串,则不需要指定第二个参数。。 回到顶部 语法 complex 语法: 1 class complex([real[, imag]]) 1 class comple 阅读全文
posted @ 2019-08-07 10:19 板岩 阅读(1758) 评论(0) 推荐(0) 编辑
摘要: python提示AttributeError: 'NoneType' object has no attribute 'append' Python问题——AttributeError: 'NoneType' object has no attribute 'append' 把lt= lt.appe 阅读全文
posted @ 2019-07-31 22:45 板岩 阅读(5744) 评论(0) 推荐(0) 编辑
摘要: #AutoTraceDraw.pyimport turtle as tt.title('自动轨迹绘制')t.setup(800, 600, 0, 0)t.pencolor("red")t.pensize(5)#数据读取datals = []f = open("data.txt")for line i 阅读全文
posted @ 2019-07-30 18:17 板岩 阅读(441) 评论(0) 推荐(0) 编辑
摘要: python中break、continue 、exit() 、pass终止循环的区别 python中break、continue 、exit() 、pass区分 1、break:跳出循环,不再执行 Python break语句,就像在C语言中,打破了最小封闭for或while循环。 break语句用 阅读全文
posted @ 2019-07-26 21:06 板岩 阅读(11514) 评论(0) 推荐(0) 编辑
摘要: '''题目:连续质数计算描述补充编程模板中代码,完成如下功能:‪‬‪‬‪‬‪‬‪‬‮‬‪‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬获得用户输入数字N,计算并输出从N开始的5个质 阅读全文
posted @ 2019-07-26 21:04 板岩 阅读(507) 评论(0) 推荐(0) 编辑
摘要: Python中for循环搭配else的陷阱 假设有如下代码: for i in range(10): if i == 5: print 'found it! i = %s' % i else: print 'not found it ...' 你期望的结果是,当找到5时打印出: found it! 阅读全文
posted @ 2019-07-26 21:02 板岩 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 科赫曲线绘制源代码 #KochDrawV1.py import turtle def koch(size, n): if n == 0: turtle.fd(size) else: for angle in [0, 60, -120, 60]: turtle.left(angle) koch(siz 阅读全文
posted @ 2019-07-25 22:52 板岩 阅读(1236) 评论(0) 推荐(0) 编辑
摘要: #A:起始,B:中间,C:最后count=0def hanoi(n,A,B,C): global count if n==1: print("{}:{}->{}".format(1,A,C)) count+=1 else: hanoi(n-1,A,C,B) #将前n-1个盘子从A移动到B上 prin 阅读全文
posted @ 2019-07-25 08:02 板岩 阅读(135) 评论(0) 推荐(0) 编辑
摘要: #字符串反转"""#字符串自带函数方法s="123456"print(s[:])list1=s[::-1]print(",".join(list1))"""#函数递归方法def rvs(s): if s=="": return s else: return rvs(s[1:])+s[0]#s="12 阅读全文
posted @ 2019-07-24 22:11 板岩 阅读(400) 评论(0) 推荐(0) 编辑
摘要: python字符串与列表的相互转换 学习内容: 1.字符串转列表 2.列表转字符串 1. 字符串转列表 str1 = "hi hello world" print(str1.split(" "))输出:['hi', 'hello', 'world'] 2. 列表转字符串 l = ["hi","hel 阅读全文
posted @ 2019-07-24 11:02 板岩 阅读(243) 评论(0) 推荐(0) 编辑