![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python基础
mxxxkuku
这个作者很懒,什么都没留下…
展开
-
PyCharm运行不自动结束问题
原因:文件命名中含有Test解决方法:重新命名原创 2020-05-16 11:38:05 · 5598 阅读 · 2 评论 -
Python 匿名函数的一些使用
加减乘除等函数:只有一行简单代码的函数使用匿名函数add = lambda a,b:a+bsub = lambda a,b:a-bmul = lambda a,b:a*bdiv = lambda a,b:a/bexp = lambda a,b:a**bcom = lambda cal,a,b:cal(a,b) #复合,cal存储方法名s = input().split(...原创 2019-09-19 21:07:15 · 193 阅读 · 0 评论 -
Python小练习0001,0002,0004
题目链接https://github.com/Yixiaohan/show-me-the-code?utm_source=wechat_session&utm_medium=social&utm_oi=7227282397426155520001做为 Apple Store App 独立开发者,你要搞限时促销,为你的应用生成激活码(或者优惠券),使用 Pytho...原创 2019-07-27 11:22:12 · 300 阅读 · 0 评论 -
Python 快速归并堆基数排序
1、快速排序 (1 数列中选择基准数字 (2 其他元素与基准比较,比基准小的放左边,大的放右边 (3 递归(2)#快排def quick_sort(data): if (len(data)) < 2: #递归直到数列里面只有一个数 return data else: mid = data[len(data)//2...原创 2019-07-24 10:31:07 · 142 阅读 · 0 评论 -
Python语法基础(二)
字符#strings = "qwert"s[2:4]s = ['q','w','e','r','t']s[2:4]list#def 方法def how_many_days(month): days_in_month = [0,31,28,31,30,31,30,31,31,30,31,30,31] return days_in_month[month...原创 2019-07-13 11:06:52 · 824 阅读 · 0 评论 -
Python基础语法(一)
打印,三个单引号原样输出print("Hello world")print("Hello\ world")print("Hello world\n","Hello world")s = '''This is the first line This is the second line'''print(s)输出格式#居中s = 'I like...原创 2019-07-12 10:01:13 · 180 阅读 · 0 评论 -
python有关安装
anaconda安装https://www.anaconda.com/distribution/路径:E:\Python\Anaconda3环境变量配置https://www.cnblogs.com/jpfss/p/8608204.html安装PyCharmhttps://www.runoob.com/w3cnote/pycharm-windows-install.htm...原创 2019-07-11 17:47:33 · 91 阅读 · 0 评论 -
Python 语法基础练习(一)
题目和代码参考:https://github.com/jackfrued/Python-100-Days循环练习:1、九九乘法表#九九乘法表for i in range(1,10): for j in range(1,i+1): print('%d * %d = %-3d'%(j,i,i*j),end=" ") print('\n')2、判断素数...原创 2019-07-16 09:40:37 · 663 阅读 · 0 评论 -
Python 面向对象 构造、继承
构造方法 自动调用 前后两个横线#无参构造class Myclass: def __init__(self): self.data = 'a' print(self.data)x = Myclass()#带参构造class area: def __init__(self,height,weight): ...原创 2019-07-14 20:55:24 · 136 阅读 · 0 评论 -
Python语法基础(四)
捕获异常a = 10try: a / 0except: print("error")迭代器#迭代器,往前访问元素list_ = [1,2,3,4]it = iter(list_)'''for x in it: print(x,end="..")'''while True: try: print (next(it))...原创 2019-07-14 19:20:25 · 105 阅读 · 0 评论 -
Python time.clock在Python3.3废弃,在Python3.8中将被移除
报错:DeprecationWarning: time.clock has been deprecated in Python 3.3 and will be removed from Python 3.8: use time.perf_counter or time.process_time insteadclock使用:from time import clockde...原创 2019-07-13 19:58:19 · 19306 阅读 · 1 评论 -
Python语法基础(三)
if --elif--elsex = int(input("Please enter an integer:"))if x < 0: x = 0 print("Negative changed to zero")elif x == 0: print("zero")else: print("more")Python 无switch case...原创 2019-07-14 09:05:53 · 156 阅读 · 0 评论