1 Star 0 Fork 0

野哥(沐野)/first_python_learn

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
day_06.py 5.27 KB
一键复制 编辑 原始数据 按行查看 历史
Admin 提交于 2023-08-02 01:08 . '字符串所有方法完毕'
# li = ('w','e','u','g')
# print(str.join(li))
#列表生成器
# print([i for i in range(1,10)])
#
# li = [i*(i+1) for i in range(1,10)]
# print(li)
# str = "hello, my name is as,I am 25 years old this year";
#
# print(str.isdecimal())
# if '25 years' in str:
# print("25 years")
# else:
# print('找不到')
# string = "Hello World"
# index = string.index('o')
# print(index)
# str = "hello, my name is as,I am 25 years old this year"
# for i in str.split(' '):
# if i.isdigit():
# print(i)
# print(str[2:3]) #使用截取方式,用正序进行截取
# print(str[2:-6])#使用截取方式,正序和倒序混合使用
# print(str[-7:-6])#使用截取方式,使用倒序进行截取
# print(str[-7])#使用负索引获取单个字符C
# print(str[2])#使用正索引获取单个字符C
# str="W3cschool"
# print(str[:3])
# print(str[-6:-3])
# name = "小明"
# age = 10
# print('我叫 %s 今年 %d 岁!'%(name,age))
# x = 1
# print(f'{x+1}')
# print(f'{x+1=}')
# str = 'abc def'
# print(str.title())
# print(str.capitalize())
# str = "[helloworld]"
# print(str.center(40,'*'))
# str = "helloworld"
# sub = 'o'
# print(str.count(sub))
# print(str.count('o',0,10))
# print(str.count('l',0,10))
# str = 'Helloworld教程'
# str_utf8 = str.encode("UTF-8")
# str_gbk = str.encode("GBK")
# print(str)
# print("UTF-8 编码",str_utf8)
# print("GBK 编码",str_gbk)
# str = "W3Cschool教程";
# str_utf8 = str.encode("UTF-8")
# str_gbk = str.encode("GBK")
#
# print(str)
#
# print("UTF-8 编码:", str_utf8)
# print("GBK 编码:", str_gbk)
#
# print("UTF-8 解码:", str_utf8.decode('UTF-8','strict'))
# print("GBK 解码:", str_gbk.decode('GBK','strict'))
# Str = "helloworld!!!!!"
# suffix = "!!!!!"
# print(Str.endswith(suffix))
# print(Str.endswith(suffix,20))
# str1 = "helloworldass"
# str2 = "ass"
#
# print(str1.find(str2))
#
# print(str1.find('w',0,6))
# str1 = "helloworldass"
# str2 = "ass"
#
# print(str1.index(str2))
# #
# # print(str1.index('w',0,2))
# print(str1.index('w',0,7))
# str = "you121212"
# print(str.isalnum())
# str1 = "wewe..wewe"
# print(str1.isalnum())
# str = "helloworld"
# str = "1234556"
# print(str.isalpha())
# str = '121212121'
# str1 = 'helloworld123456789'
# print(str.isdigit())
# print(str1.isdigit())
# print(str.isnumeric())
# print(str1.isnumeric())
# str = 'helloworld'
# print(str.islower())
# str = "helloworld "
# str1 = " "
# print(str.isspace())
# print(str1.isspace())
# str = "Hello World Ass"
# print(str.istitle())
# str1 = "Hello world ass"
# print(str1.istitle())
# str = "HELLO WORLD ASS"
# print(str.isupper())
# str1 = "hello world ass"
# print(str1.isupper())
# str1 = "-"
# str2 = "*"
# seq = ("h","e","l","l","o","w","o","r","l","d")
# print(str1.join(seq))
# print(str2.join(seq))
# len
# str = "hello world , My name is Ass"
# print(len(str))
# list = ['h','e','l','l','o']
# print(len(list))
# dict = {'name':'ass','age':18,'height':170}
# print(len(dict))
# ljust rjust
# str = 'hello world'
# print(str.ljust(30,'$'))
# print(str.rjust(30,'$'))
# lower
# str = 'HELLO WOLRD'
# print(str.lower())
# lstrip()
# str = ' hello world'
# str1 = 'hhello world '
# str2 = 'hello worlddddd'
# print(str.lstrip())
# print(str1.rstrip())
# print(str1.lstrip('h'))
# print(str2.rstrip('d'))
# maketrans() ????
# str1 = 'ass'
# str2 = '234'
#
# str = 'this is string example'
# str3 = str.maketrans(str1,str2)
#
# print(str.translate(str3))
# max min
# str = 'hello world'
# print(max(str))
# # print(min(str)) 输出空格
# str1 = 'HelloWorld'
# print(min(str1))
# str2 = 'helloworld'
# print(min(str2))
# replace()
# str = 'hello world , my name is ass , I am learn python'
# print(str)
# print(str.replace('python','python3'))
# print(str.replace('o','WW',3))
# print(str.replace('o','WW',2))
# rfind()
# str = 'hello world , my name is ass , I am learn python'
# print(str.rfind('o'))
# print(str.rfind('o',0,10))
# print(str.rfind('o',5,0))
#
# print(str.find('o'))
# print(str.find('o',0,10))
# print(str.find('o',10,0))
#rindex
# str = 'hello world'
# print(str.index('e'))
# print(str.index('o',0,9))
# # print(str.rindex('o',0,5))
# print(str.rindex('o',0,8))
# rjust
# str = 'hello world'
# print(str.rjust(40,'*'))
# print(str.ljust(40,'*'))
# split
# str = 'hello world,My nameo iso ass'
# print(str.split())
# # print(str.split('o',3))
# print(str.split('w'))
# splitlines
# str = "this is \nstring example....\nwow!!!"
# print(str.splitlines())
# startswith()
# str = "this is string example....wow!!!"
# print(str.startswith('this'))
# print(str.startswith('is',2))
# print(str.startswith('is',8))
# print(str.startswith('this',1,4))
#swapcase()
# str = 'HELLO WORLD'
# str1 = 'hello world'
# str3 = 'Hello World'
# print(str.swapcase())
# print(str1.swapcase())
# print(str3.swapcase())
# upper
# str = "this is string example from w3cschool....wow!!!";
# print (str.upper())
# title()
# str = "this is string example from youj....wow!!!"
# print (str.title())
# translate
# intab = "aeiou"
# outtab = "12345"
# trantab = str.maketrans(intab, outtab)
#
# str = "this is string example....wow!!!"
# print (str.translate(trantab))
# zfill
# str = "this is string example from youj....wow!!!"
# print (str.zfill(40))
# print (str.zfill(50))
# isdecimal
str = "youj2016"
print (str.isdecimal())
str = "23443434"
print (str.isdecimal())
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/ye-ge-mu-ye/first_python_learn.git
git@gitee.com:ye-ge-mu-ye/first_python_learn.git
ye-ge-mu-ye
first_python_learn
first_python_learn
master

搜索帮助