#!/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. couchbase的备份与恢复命令

    下面技术应用于最优质的水果的鲜果篮 ./cbbackup http://192.168.1.112:8091 /backups/20140505 -u Administrator -p passwor ...

  2. CMMI的SG/GG概念区别与SP/GP概念的区别

    每一个 “流程区域” 会细分为多个子目标.若该子目标只对应单一的流程区域,称为 “特定目标(Specific goal)”:若子目标会涵跨多个流程区域,则称为 “一般目标(Generic goal)” ...

  3. 原生JS---7

    原生js学习笔记7——本地存储之cookie操作 什么是cookie • 用来保存页面信息的,如用户名.密码 • cookie的特性:同一个网站中所有的页面共享一套cookie:数量.大小限制:过期时 ...

  4. mybatis的二级缓存

    在mybatis主配置文件里configuration标签里添加 <settings> <setting name="cacheEnabled" value=&q ...

  5. File入门及路径名问题

    package com.io.file; import java.io.File; /** * @author 王恒 * @datetime 2017年4月20日 下午2:53:29 * @descr ...

  6. C#比较两个日期的大小 .net

    using System;using System.Collections; public class MyClass{public static void Main(){DateTime dt1 = ...

  7. CABasicAnimation - 上下滑动动画

    #import <UIKit/UIKit.h> @interface TJProgressView : UIView @property(nonatomic,assign)CGFloat ...

  8. 利用 html+css 画同心圆(concentric circles)——绝对布局与相对布局

    一.css 绘制圆 #circle { width: 300px; height: 300px; background-color: #000000; border-radius: 300px; } ...

  9. html与css命名规范小结

    一.命名规则说明 所有的命名最好都用小写 使用英文命名 给每一个表格和表单加上一个唯一的.结构标记id 给每个图片加上alt标签,优点在于图片发生错误时,alt可以体现给用户 二.相对网页外层重要部分 ...

  10. spring data jpa 、hibernate、jpa之间的关系

    引用:http://blog.csdn.net/u014421556/article/details/52635000 hibernate作为JPA的实现.   JPA规范与ORM框架之间的关系   ...