python3
_忽如一夜春风来
Talk is cheap,Show me the code !
展开
-
1.环境配置
linux 乌班图18.04, 改变默认python指向为python3 查看替换版本python信息 输入update-alternatives --list python 如果报错就先输入 sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1 sudo update-alterna...原创 2019-09-29 10:58:20 · 119 阅读 · 0 评论 -
2. python 基础语法分支和循环语句
循环语句以及IF和注释 while True: print("This is True") if True: print("This is IF True") elif False: print("This is ElIf False") else: print("this is no") # 这里是单行注释 ''' 这里是多行注释 ''' ...原创 2019-09-29 10:58:53 · 166 阅读 · 0 评论 -
3. Python3 练习问题
如何四舍五入 # 平常使用int()时向下截断,现要求四舍五入 # 一位小数的时候 temp = 5.3 if int(temp + 0.5) == 6 print("值为6") elif int(temp + 0.5) == 5 print("值为5") ''' 5.4 “四舍五入”结果为:5,int(5.4+0.5) == 5 5.6 “四舍五入”结果为:6,int(5.6+0.5...原创 2019-09-29 10:59:31 · 164 阅读 · 0 评论 -
4.列表
""" 列表常用方法 """ #添加元素 ar = [1,2,3,4] ar += [5] # ar: [1,2,3,4,5] ar.append(6) #ar: [1,2,3,4,5,6] ar.insert(7,7) #ar: [1,2,3,4,5,6,7] ar.extend([8,9]) #ar: [1,2,3,4,5,6,7,8,9] ar[1] # 2 #删除元素 ar....原创 2019-09-29 11:04:48 · 113 阅读 · 0 评论