#!/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 第三天的更多相关文章

  1. 孤荷凌寒自学python第三十九天python 的线程锁Lock

    孤荷凌寒自学python第三十九天python的线程锁Lock (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 当多个线程同时操作一个文件等需要同时操作某一对象的情况发生时,很有可能发生冲突, ...

  2. 孤荷凌寒自学python第三十八天初识python的线程控制

     孤荷凌寒自学python第三十八天初识python的线程控制 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 一.线程 在操作系统中存在着很多的可执行的应用程序,每个应用程序启动后,就可以看 ...

  3. 孤荷凌寒自学python第三十七天python的文件与内存变量之间的序列化与反序列化

    孤荷凌寒自学python第三十七天python的文件与内存变量之间的序列化与反序列化 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 一.什么是序列化与反序列化 序列化是指将内存中的数据进行指 ...

  4. 孤荷凌寒自学python第三十五天python的文件操作之针对文件操作的os模块的相关内容

     孤荷凌寒自学python第三十五天python的文件操作之针对文件操作的os模块的相关内容 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 一.打开文件后,要务必记得关闭,所以一般的写法应当 ...

  5. 孤荷凌寒自学python第三十四天python的文件操作对file类的对象学习

     孤荷凌寒自学python第三十四天python的文件操作对file类的对象学习 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 一.close() 当一个file对象执行此方法时,将关闭当前 ...

  6. 孤荷凌寒自学python第三十三天python的文件操作初识

     孤荷凌寒自学python第三十三天python的文件操作初识 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 今天开始自学python的普通 文件操作部分的内容. 一.python的文件打开 ...

  7. 孤荷凌寒自学python第三十一天python的datetime.timedelta模块

     孤荷凌寒自学python第三十一天python的datetime.timedelta模块 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) datetime.timedelta模块是一个表示 ...

  8. 孤荷凌寒自学python第三十天python的datetime.datetime模块

     孤荷凌寒自学python第三十天python的datetime.datetime模块 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) datetime.datetime模块包含了:datet ...

  9. 孤荷凌寒自学python第三天 初识序列

    孤荷凌寒自学python第三天 初识序列 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) Python的序列非常让我着迷,之前学习的其它编程语言中没有非常特别关注过序列这种类型的对象,而pyt ...

随机推荐

  1. jenkins配置邮箱遇到的问题

    错误一:发送测试邮件测试配置没有填写接收者的邮箱 原因:没有写接收者的邮箱 2.写了接受者的邮箱 密码错误 解决办法:qq邮箱>设置>账户,发送短信后点我已发送,就会接收到密码 3.发送时 ...

  2. 解析HTTP协议六种请求方法

    标准Http协议支持六种请求方法,即: 1,GET 2,HEAD 3,PUT 4,DELETE 5,POST 6,OPTIONS 但其实我们大部分情况下只用到了GET和POST.如果想设计一个符合RE ...

  3. ortp库使用入门

    我们知道, RTP(Real-timeTransportProtocol)是用于Internet上针对多媒体数据流的一种传输协议,做流媒体传输方面的应用离不开RTP协议的实现及使用,为了更加快速地在项 ...

  4. Python开发利器PyCharm 2.7附注册码

    PyCharm 2.7 下载 http://download.jetbrains.com/python/pycharm-2.7.2.exe 激活注册 user name:EMBRACE key: 14 ...

  5. Django day07 (二)单表操作

    单表操作 -mysql数据库:settings里配置: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME ...

  6. HDU3533 Escape

    题目: The students of the HEU are maneuvering for their military training. The red army and the blue a ...

  7. 【POJ2248、LOJ#10021】 Addition Chains

    事先预警:由于我太蒻了,本做法只能在POJ.LOJ等小数据(N<=100)平台上通过,在UVa(洛谷)上大数据并不能通过 戳我获得更好的观看效果 本题不用看,爆搜就是了,但是纯爆搜显然会爆时间, ...

  8. Run as ant build每次都执行两次

    因为用了selenium+testng+ant的框架,所以每次执行自动化,我就run as ant build.发现测试每次都执行两次,很奇怪.因为也没有影响到测试结果,所以一开始也就let it g ...

  9. C# 多线程系列(二)

    传递数据给一个线程 通过函数或lambda表达式包一层进行传递. static void Main(string[] args) { Thread thread = new Thread(() =&g ...

  10. cookie/session在nodes中的实战

    cookie 和 session 众所周知,HTTP 是一个无状态协议,所以客户端每次发出请求时,下一次请求无法得知上一次请求所包含的状态数据,如何能把一个用户的状态数据关联起来呢? 比如在淘宝的某个 ...