python 2018/8/25
# 含多空格字符串的分割
hello = "hello python hello"
print(a.split(" ")) # ['hello', 'python', '', 'hello']
print(hello.split()) # ['hello', 'python', 'hello']
print(len(a.split(" ")[2])) # ''也是一个字符串类型数据,只是什么都没有 # 0
print(a.split(" ")[2]) # 没有任何内容
print(type(a.split(" ")[2])) # <class 'str'> 字符串类型
# 字符串定义
hello = """hello python""" # hello python
hell0 = ""hello python"" # SyntaxError: invalid syntax
list1 = [10,3.13,'hello',True]
list1.append(3)
print(list1)
list1[2] = '你好'
print(list1)
list1.remove('你好')
print(list1)
# list1.remove('nihao') # ValueError: list.remove(x): x not in list
list1.pop(-2)
print(list1)
# 关于del的两种删除方式
del list1[0]
print(list1)
del(list1[0])
print(list1)
#关于while的break
内循环里执行 break 不会导致外循环一起结束
j = 0
while j < 3:
print("外层运行中")
i = 0
while i < 6:
if i ==4:
break
print("内层运行中")
i += 1
if j ==2:
break
j += 1
名片管理系统
while True:
print("欢迎使用ITV1.0")
active = True
while True:
if active:
name = input("请输入姓名:(按q退出)")
if name == 'q':
break
length_name = len(name)
if (length_name < 6) or (length_name > 20):
print("长度错误")
continue
else:
pass
while True:
if active:
tel = input("请输入手机号:(按q返回上一级)")
if tel == 'q':
break
length_tel = len(tel)
if length_tel != 11:
print("长度不合法")
continue
else:
pass
while True:
sex = input("请输入性别:(按q返回上一级)")
if sex == 'q':
break
if sex == '男' or sex == '女':
print("录入成功")
active = False
else:
print("性别错误")
continue
print("*" * 5 + "名片信息" + "*" * 5)
print("姓名:%s" % name)
print("手机号: %s" % tel)
print("性别:%s" % sex)
break
else:
break
else:
break
ask = input("是否继续录入信息?y/n")
if ask == 'n':
print("谢谢使用V1.0")
break
python 2018/8/25的更多相关文章
- Python天天美味(25) - 深入理解yield
Python天天美味(25) - 深入理解yield - CoderZh - 博客园 Python天天美味(25) - 深入理解yield yield的英文单词意思是生产,刚接触Python的时候 ...
- 2018/04/25 基于 编译安装的 PHP7 安装 swoole 扩展
在上一篇文章我们知道了如何去编译安装一个自己需要的 PHP 版本. 2018/04/25 PHP7的编译安装 这里还没有完,我们还需要安装我们的扩展,才算完成今天的任务. -- 下载扩展 还是官网下载 ...
- 我的Python成长之路---第八天---Python基础(25)---2016年3月5日(晴)
多进程 multiprocessing模块 multiprocessing模块提供了一个Process类来代表一个进程对象 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ...
- 【python之路25】正则表达式
一.正则表达式简介 就其本质而言,正则表达式(或RE)是一种小型的.高度专业化的(在python中),它内嵌在python中,并通过RE模块实现.正则表达式编译成一系列字节码,然后由用C编写的匹配引擎 ...
- python 代码片段25
#coding=utf-8 # 虽然python是面向对象的语言,但是没有显式的构造函数概念. # python没有new关键词 class MyClass(object): pass m=MyCla ...
- Python入门笔记(25):Python面向对象(2)
一.类 类就是一个数据结构,封装了数据和操作. 类的声明与函数的声明十分类似: class newClass(object): """class documentatio ...
- python学习笔记25(文件管理 os包)
os包我们经常会与文件和目录打交道,对于这些操作python提供了一个os模块,里面包含了很多操作文件和目录的函数.如果你对linux基本操作了解的话,下面的一些os方法应该会很熟悉的,因为基本和li ...
- python学习第25天
异常处理 什么是异常?什么是错误? 1,程序中难免出现错误. 错误主要分为两种: 1,语法错误 语法错误是根本上的错误,无法通过PYTHON解释器.完全无法执行,是在程序中不应该出现的错误.无法进行异 ...
- 2018.11.25 AMC-ICPC 亚洲区域赛(焦作站)吊银
11月23日 大清早,跟着wyb的脚步,早起跑过去听方伟的编译原理,然鹅一点都没听进去,在焦作胡辣汤群里疯狂灌水... 听说焦作那边冷得不行,前一天看天气预报说那边已经是2℃了,都快零下了,然鹅学校里 ...
随机推荐
- Codeforces732D Exams
显然要二分答案,然后对于一个天数,我们来判断是否可以通过所有考试,这里就贪心来安排就好了. 首先我们希望每门课的考试时间越晚越好,然后就是先复习最早开始的考试. #include <bits/s ...
- 笔记:JavaScript闭包
闭包 闭包是一种保护私有变量的机制,在函数执行时形成私有的作用域,保护里面的私有变量不受外界干扰.直观的说就是形成一个不销毁的栈环境. 对于闭包,当外部函数返回之后,内部函数依然可以访问外部函数的变量 ...
- IIS7的FTP出错: 451 No mapping for the unicode character exists in the target multi-byte code page
提示:IIS7的FTP出错: 451 No mapping for the unicode character exists in the target multi-byte code page 今天 ...
- iOS bounds vs frame
斯坦福iOS开发课程的白胡子大叔的PPT解释得淋漓尽致!
- jsp 接收汉字参数乱码
这两天跟汉字问题较上劲了,真是考验基本功 1. ${param.userName} 乱码 解决方法: <%String name = (String)request.getParameter( ...
- android ViewPager 与Fragment
ViewPager 左右滑动数据显示 1. 整体布局 FragmentLayout 容器包裹Fragment <?xml version="1.0" encoding=&qu ...
- LBP特征
此篇摘取 <LBP特征原理及代码实现> <LBP特征 学习笔记> 另可参考实现: <LBP特征学习及实现> <LBP特征的实现及LBP+SVM分类> & ...
- 转:从《The C Programming Language》中学到的那些编程风格和设计思想
这儿有一篇写的很好的读后感:http://www.cnblogs.com/xkfz007/articles/2566424.html 读书不是目的,关键在于思考. 很早就在水木上看到有人推荐& ...
- 关于MyBatis的两种写法
刚接触MyBatis是在Jike的视频中学习的,但是之后又发现和项目中的MyBatis的用法不太一致.上网找了好多资料,发现网上的教程分为两种写法: 第一种,是jike视频中的写法,写好map.xml ...
- STM32CUBEMX使用注意:
一 注意堆栈大小,简单来说,栈空间用于局部变量空间(size=0x400一般够用),堆(size=0x200一般够用)空间用于 alloc 或者 malloc函数动态申请变量空间