当前位置:网站首页>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 边栏推荐
- 利用kubernetes資源鎖完成自己的HA應用
- Blog publishing test 1
- e. Difference between target and e.currenttarget
- 目标检测——ADAS实战
- QT basics tutorial: qstringlist
- How to become a senior digital IC Design Engineer (4-2) script: file read / write operation realized by Verilog HDL code
- How to use project Gantt chart to make project report
- Koa 快速入門
- 学习太极创客 — MQTT 第二章(九)本章测试
- What is the dry goods microservice architecture? What are the advantages and disadvantages?
猜你喜欢

HBuilder左侧工具栏不见了

What is the dry goods microservice architecture? What are the advantages and disadvantages?

How to become a senior digital IC Design Engineer (4-3)
![[high concurrency, high performance and high availability of massive data MySQL practice-10] - Implementation of mvcc in InnoDB](/img/dc/a30ccd9943e668aef8c874980a4975.jpg)
[high concurrency, high performance and high availability of massive data MySQL practice-10] - Implementation of mvcc in InnoDB

Dialogue with opensea co creation Alex: we still only touch the tip of the iceberg of NFT capability | chain catcher

SystemVerilog structure (I)

Tiflash compiler oriented automatic vectorization acceleration

项目研发,有哪些好用的免费脑图工具软件

CTFHub-Web-密码口令-弱口令

Koa 快速入门
随机推荐
温度转换 II
SystemVerilog structure (I)
[redis] key hierarchy
CTFHub-Web-SQL注入-整数型注入
哪个证券公司最大最安全 哪家券商服务好
[從零開始學習FPGA編程-49]:視野篇 - 芯片是如何被設計出來的?
What is stock online account opening? Is it safe to open an account online?
如何成为一名高级数字 IC 设计工程师(6-6)数字 IC 验证篇:系统级仿真
Finally got the byte offer. The 25-year-old inexperienced experience in software testing is written to you who are still confused
Blog publishing test 2
扁平结构转换为树结构
MySQL的下载和安装
[high concurrency, high performance and high availability of massive data MySQL practice-10] - Implementation of mvcc in InnoDB
Why install an SSL certificate on a web site?
如何成为一名高级数字 IC 设计工程师(4-5)脚本篇:Shell 脚本实现的文件比较操作
如何成为一名高级数字 IC 设计工程师(5-1)理论篇:时钟技术、复位技术
Studies of relative costs for development in different languages
Tiflash compiler oriented automatic vectorization acceleration
“内窥镜第一股”二闯IPO,去年亏损5个亿,核心产品商业化仍存疑 | IPO速递
Troubleshooting of pyinstaller failed to pack pikepdf