自学python 第三天
- #!/usr/bin/env python
# -*- coding:utf-8 -*-- # name = "***"
# if "*" in name:
# print('帅哥')
# else:- # a = 123
#
# v = a.bit_length()
# print(v)
#type表示类型,(具体字符还是,数字)
# a = "999"
# print(type(a),a)
# b = int(a)
# print(type(b),b)
#base是表示多少进制
# num = "0011"
# v= int(num,base=8)
# print(v)- # name = "sdadhsja"
# age = "18"
# info = name + age
# print(info) sdadhsja18- #**********一个深灰魔法***************
# 字符串一旦创建就不可修改
# 一旦修改或者拼接,都会造成重新生成字符串- #******7个基本魔法*******
# join 加入
# split 分割
# find 查找
# strip 去除
# upper 转换为大写字母
# lower 转换为小写字母
# replace 替换
# test = "alexalexalex"
# v = test.replace("ex",'cc',2)
# print(v) alccalccalex
#******4个灰魔法*******
# test = "alex"
# v = test[3] 索引,下标,获取字符窜中的某一个字符
# print(v) x
#字符(.format)的用法- # test = "alex"
# v = test[0:2] 0<= <1 【切片】
# print(v) al
# test = "alex"
# v = len(test) 获取当前字符窜中由几个字符组成【Python3】
# print(v)
#注意: 在其他语言中也有用法
# len("sdas")
# "__".join("skahdaidja")
#test = "计算机的发展史没有很"
#
# index = 0
# while index<len(test):
# v = test[index]
# print(v)
#
# index += 1
# print('======')
# 计
# 算
# 机
# 的
# 发
# 展
# 史
# 没
# 有
# 很
# ======
# for 循环 【for变量名 in 字符串:】 【索引,切片也能用】
# 变量名
# test = "郑建文妹子有种冲我来"
# for zjw in test:
# print(zjw)
# 郑
# 建
# 文
# 妹
# 子
# 有
# 种
# 冲
# 我
# 来- # test = 'i am {name},age{a}' name,age。可以换成0,1
# print(test)
# v = test.format(name='alex',a='19')
# print(v)- # 字符(.find)的用法 从开始往后找,找打第一个之后 ,获取位置(位置可以自己定义)
# test ="alexalex"
# v = test.find('x',5,8) (表示从几位开始到几位结束)
# print(v) (当找不到时,会显示‘-1’)- #字符.index的用法 (当找不到时会报错)
# test = "alexalex"
# v = test.index('x')
# print(v)- #字符(.isalnum)的用法 (字符窜中只能包含 数字和字母)
# test = "usdsad"
# v = test.isalnum()
# print(v)- #字符(.isalpha的用法) (字符窜中只能包含 汉字 和 字母)
# test = "sdafas可以"
# v = test.isalpha()
# print(v)- #字符(.expandtabls)的用法
# test = "username\temail\tpassword\nycj\tyang@qq.com\t123"
# v = test.expandtabs(20)
# print(v)- # 字符(.isdcimal)的用法 (当前输入是否是数字)
# test = "254655"
# v1 =test.isdecimal()
# v2 =test.isdigit()
# print(v1,v2)- #字符(.swapcase)的用法 (大小字母转换,--原来是小写换为大写,原来是小写换为大写)
# test = "nsakdlsSDH"
# v = test.swapcase()
# print(v)- #字符(.isidentifier) (字母,数字,汉语,下滑线:标志符 def class{除符号包括空格})
# a = "def____125你"
# v = a.isidentifier()
# print(v)- #字符(.isprintable)的用法 (是否存在不可显示的字符) (/t 换行) /n
# test = "sjdh/nsdsa"
# v = test.isprintable()
# print(v)
#字符(.isprintable)的用法 是否存在不可显示的字符
# test = "skduwh\tdjshd"
# # v = test.isprintable()
# # print(v)- #字符(.isspace)的用法 (判断是否全部是空格)
# test = " "
# v = test.isspace()
# print(v)- #字符(.istitle) (判断是否是大写首字母开头)
# test = "Asdfsdf"
# v = test.istitle()
# print(v)- #isdecimal,isdigit,isnumeric,字符的用法和区别:当前输入是否是数字
# test = "二" # 1, ②
# v1 = test.isdecimal()
# v2 = test.isdigit() ()
# v3 = test.isnumeric() (判断是否是标题的时候)
# print(v1,v2,v3)- #字符(.title,.istitle)的用法 (判断是否是标题)
# test = "Return True if all cased characters in S are uppercase and there is pigman"
# v1 = test.title() #转化为单词的首字母为大写字母开头
# print(v1)
# v2 = test.istitle() #判断单词首字母是否是大写字母开头
# print(v2)- #****字符(.join)的用法 (将字符窜的每一个元素按照指定的分隔符进行拼接)
# test = "你是风儿我是沙"
# print(test)
# t = ' '
# v = t.join(test)
# print(v) (你 是 风 儿 我 是 沙)- #**字符(.center)的用法 (设置宽度,并将类容居中)
# test = "2000"
# v = test.center(20) (20代指总长度)
# print(v) ( 2000 )- #**字符(.ljust)的用法 (左边为字符窜,右边为填充内容)(“*”为填充内容)
# test = "abcd"
# v = test.ljust(20,"*")
# print(v) (abcd****************)
#**字符(.rjust)的用法 右边为字符窜,左边为填充内容(“*”为填充内容)
# test = "abcd"
# v = test.rjust(20,'*')
# print(v) (****************abcd)
#字符(.zfill)的用法 不能指定填充内容
# test = "alex"
# # v = test.zfill(20) #(20代指总长度)
# # print(v) (0000000000000000alex)- #字符(.lower,.islower)的用法
# test = "Alex"
# v1 = test.islower() 判断是否全是小写
# v2 = test.lower() 全部转化为小写
# print(v1,v2) (False alex)- #字符(.upper,isupper)的用法
# test = "Alex"
# v1 = test.isupper() (判断是否全是大写)
# v2 = test.upper() (全部转化为大写)
# print(v1,v2) (False ALEX)- #字符(.lstrip,rsrip,strip) (默认去除左右空白或去除指定字母,字符)
# test = " alex "
# v1 = test.lstrip()
# v2 = test.rstrip()
# v3 = test.strip()
# print(v1,v2,v3) (alex alex alex)- #字符(.maketrans)的用法 (一一对应翻译转化,字符的一种特换)
# test = "abcd"
# test1 = "1234"
# v = "kajdak;sdasx;sdasvs"
# m = str.maketrans("abcd", "1234")
# new_v = v.maketrans(m)
# print(new_v) ({97: 49, 98: 50, 99: 51, 100: 52})- # 字符(.partition,.rpartition,.split,rsplit)的用法
# test = "testasdsddfg"
# v1 = test.partition('s') #(分割只能分两份)
# v2 = test.rpartition('s') #(分割只能分三份)
# v3 = test.split('s') #(全部分割,不包含分割的元素)
# v4 = test.rsplit('s') #()
# print(v1,v2,v3,v4) ('te', 's', 'tasdsddfg') ('testasd', 's', 'ddfg') ['te', 'ta', 'd', 'ddfg'] ['te', 'ta', 'd', 'ddfg']
#正则表达式
#是否想要分割的元素
#v = test.split('s',2)- #字符(.startswith)的用法
# test = "backend"
# v1 = test.startswith('b') #(以**开头,以**结尾)
# v2 = test.endswith('d')
# print(v1,v2) True True- # 字符(.swaprase)的用法 大小写转换
# test = "aldaLSA"
# v = test.swapcase()
# print(v) (ALDAlsa)- # test = "你是风儿我是沙"
# t = '*'
# v = t.join(test)
# print(v)
自学python 第三天的更多相关文章
- 孤荷凌寒自学python第三十九天python 的线程锁Lock
孤荷凌寒自学python第三十九天python的线程锁Lock (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 当多个线程同时操作一个文件等需要同时操作某一对象的情况发生时,很有可能发生冲突, ...
- 孤荷凌寒自学python第三十八天初识python的线程控制
孤荷凌寒自学python第三十八天初识python的线程控制 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 一.线程 在操作系统中存在着很多的可执行的应用程序,每个应用程序启动后,就可以看 ...
- 孤荷凌寒自学python第三十七天python的文件与内存变量之间的序列化与反序列化
孤荷凌寒自学python第三十七天python的文件与内存变量之间的序列化与反序列化 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 一.什么是序列化与反序列化 序列化是指将内存中的数据进行指 ...
- 孤荷凌寒自学python第三十五天python的文件操作之针对文件操作的os模块的相关内容
孤荷凌寒自学python第三十五天python的文件操作之针对文件操作的os模块的相关内容 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 一.打开文件后,要务必记得关闭,所以一般的写法应当 ...
- 孤荷凌寒自学python第三十四天python的文件操作对file类的对象学习
孤荷凌寒自学python第三十四天python的文件操作对file类的对象学习 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 一.close() 当一个file对象执行此方法时,将关闭当前 ...
- 孤荷凌寒自学python第三十三天python的文件操作初识
孤荷凌寒自学python第三十三天python的文件操作初识 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 今天开始自学python的普通 文件操作部分的内容. 一.python的文件打开 ...
- 孤荷凌寒自学python第三十一天python的datetime.timedelta模块
孤荷凌寒自学python第三十一天python的datetime.timedelta模块 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) datetime.timedelta模块是一个表示 ...
- 孤荷凌寒自学python第三十天python的datetime.datetime模块
孤荷凌寒自学python第三十天python的datetime.datetime模块 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) datetime.datetime模块包含了:datet ...
- 孤荷凌寒自学python第三天 初识序列
孤荷凌寒自学python第三天 初识序列 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) Python的序列非常让我着迷,之前学习的其它编程语言中没有非常特别关注过序列这种类型的对象,而pyt ...
随机推荐
- libcurl实现解析(3) - libcurl对select的使用
1.前言 在本系列的前一篇文章中.介绍了libcurl对poll()的使用. 參考"libcurl原理解析(2) - libcurl对poll的使用". 本篇文章主要分析curl_ ...
- codeforces Looksery Cup 2015 D. Haar Features
The first algorithm for detecting a face on the image working in realtime was developed by Paul Viol ...
- oc40--类的启动过程
// // main.m // 类的启动过程 #import <Foundation/Foundation.h> #import "Person.h" #import ...
- mac os lscpu 【转】
CPU Information on Linux and OS X This is small blog post detailing how to obtain information on you ...
- pull的时候报错
- hdu3853LOOPS(概率与期望dp)
LOOPS Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 125536/65536 K (Java/Others)Total Sub ...
- DIV+CSS设计时浏览器兼容性
近期用Div+css做了个企业网站,在浏览器中测试的时候确发现在IE7中显示正常的页面,在ie6中非常混乱,当时第一感觉就想到了兼容问题,可是百思不得其解应该从哪下手,经过一两天的查资料, ...
- NPM 国内镜像使用方法
npm官方站点: http://www.npmjs.org/ 本文使用国内镜像地址: http://www.cnpmjs.org/ 搜索镜像:https://npm.taobao.org/ 具体方法: ...
- [转]浏览器缓存详解: expires, cache-control, last-modified, etag详细说明
最近在对CDN进行优化,对浏览器缓存深入研究了一下,记录一下,方便后来者 画了一个草图: 每个状态的详细说明如下: 1.Last-Modified 在浏览器第一次请求某一个URL时,服务器端的返回状态 ...
- android黑科技系列——Android中新型安全防护策略
一.前言 最近有一个同学,发给我一个设备流量访问检测工具,但是奇怪的是,他从GP上下载下来之后安装就没有数据了,而在GP上直接安装就可以.二次打包也会有问题.所以这里就可以判断这个app应该是有签名校 ...