当前位置:网站首页>String attribute exercise
String attribute exercise
2022-06-29 02:19:00 【Long street 395】
describe
Basic operation of string
| The operator | describe |
|---|---|
| s + t | Splice two sequences s and t |
| s * n or n * s | The sequence of s repeat n Generate new sequence |
| s[i] | Indexes , Return sequence s Of the i term |
| s[start:end[:step]] | section , Return sequence s from start To end ( barring end ) For the step length step Generate a new sequence of characters ,step By default , In steps of 1, Return sequence number from start To end The subsequence . |
| len(s) | Return sequence s The length of ( Contains the number of elements ) |
| min(s,*[,key, default]) | Return sequence s The minimum value of ,key Keywords are compared by element value by default |
| max(s,*[,key, default]) | Return sequence s The maximum of ,key Keywords are compared by element value by default |
| s.count(x) | Sequence s in x The number of |
| s.index(x[, i[, j]]) | The first in the sequence x The index of the value ,i Value indicates from the index i Start looking for x,j Express x The search scope is i and j Between . |
| x in s | If the sequence x And sequence s Any subsequence in is equal , return True, Otherwise return to False; When x And s Returns when the elements of are equal True, Otherwise return to False. |
| x not in s | If the sequence x And sequence s Any subsequence in is not equal , return True, Otherwise return to False |
Please refer to the above table , Complete the template program according to the requirements of the notes .
id = input() # Enter the student id
name = input() # Enter a name
print(id,name,sep='') # Output student ID name , No space in the middle
print(name*5) # Repeat output name 5 All over , No space in the middle
s = ' People can walk , There's a way to walk ' # This is a string
n=int(input()) # Receive an integer input n
print(s[n]) # Output string s The number in is n The characters of
print(s[0::2])# Output string s Characters with even serial numbers in
print(s[::-1]) # Output the string in reverse order
print(len(s)) # Output string s The length of
print(len(s[n::])) # Output string s From the serial number n The number of characters to the end of the string ( Including serial number n The characters of )
print(s.count(' road ')) # Output string s Substring ‘ Walk ’ The number of
print(s.find(' go ')) # Output string s In the character ‘ go ’ The first occurrence of the position sequence number
test = input() # Enter a string
print(test in s) # test test Whether in s in , Output the test results 边栏推荐
- [从零开始学习FPGA编程-49]:视野篇 - 芯片是如何被设计出来的?
- QT basics tutorial: qstringlist
- Why is it recommended that you choose the self research company as much as possible
- [redis] hash type
- Com3529 test analysis
- [learning notes] subsets and questions
- Wechat campaign auto like
- 网上联系客户经理办理炒股开户安全吗?
- The linkedhashset set makes the elements orderly without repetition
- Blog publishing test 1
猜你喜欢

SystemVerilog structure (I)

Live broadcast preview | can SQL also play industrial machine learning? Mlops meetup V3 takes you to the bottom!
![[redis] list type](/img/c7/adec2aaea50d69a0aed95bfe683b9e.png)
[redis] list type

Configurable FFT system design based on risc-v SOC (1) Introduction

CTFHub-Web-密码口令-默认口令

I have summarized some experiences from the whole process of R & D platform splitting

如何成为一名高级数字 IC 设计工程师(4-3)脚本篇:C 语言实现的文件读写操作

Crawler exercise (IV) -- IP address problem

Koa 快速入门

Koa quick start
随机推荐
Koa 快速入门
如何成为一名高级数字 IC 设计工程师(4-2)脚本篇:Verilog HDL 代码实现的文件读写操作
[redis] key hierarchy
Is the ETF fund reliable and safe
Why is it recommended that you choose the self research company as much as possible
为什么要在网站上安装SSL证书?
计算矩形面积
Koa 快速入門
e.target与e.currentTarget的区别
Koa quick start
Scala 基礎 (三):運算符和流程控制
Understand flex layout in an article
扁平结构转换为树结构
Blog publishing test 3
Finally got the byte offer. The 25-year-old inexperienced experience in software testing is written to you who are still confused
What is the Valentine's Day gift given by the operator to the product?
QT basics tutorial: data types and containers
How to become a senior digital IC Design Engineer (6-6) digital IC Verification: system level simulation
Learning Tai Chi Maker - mqtt Chapter II (IX) test of this chapter
[redis] data introduction & General Command & string type