当前位置:网站首页>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 边栏推荐
- QT basics tutorial: data types and containers
- 在按钮禁用时消除hover效果
- [learn FPGA programming from scratch -49]: Vision - how is the chip designed?
- 组合数据类型之元组小练习
- How to become a senior digital IC Design Engineer (5-1) theory: clock technology, reset Technology
- 如何成为一名高级数字 IC 设计工程师(4-5)脚本篇:Shell 脚本实现的文件比较操作
- HBuilder左侧工具栏不见了
- Which is the best billing method for okcc call center
- 字符串属性练习
- okcc呼叫中心的计费方式哪个最好
猜你喜欢

【Redis】Key的层级结构

KOA Quick Start

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

Crawler exercise (IV) -- IP address problem

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

Oculusrifts and unity UI interaction (1) - Overview

How to use project Gantt chart to make project report

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

【Redis】Hash类型
![[redis] key hierarchy](/img/ab/a5d3bb61b4571966d0f47037af4f41.png)
[redis] key hierarchy
随机推荐
Convert flat structure to tree structure
Why is it recommended that you choose the self research company as much as possible
Boost the digital economy and face the future office | the launch of the new version of spreadjsv15.0 is about to begin
如何成为一名高级数字 IC 设计工程师(4-2)脚本篇:Verilog HDL 代码实现的文件读写操作
Fundamentals of scala (3): operators and process control
【Redis】数据介绍 & 通用命令 & String类型
CTFHub-Web-SQL注入-整数型注入
MySQL details - aggregation and grouping
e. Difference between target and e.currenttarget
[redis] key hierarchy
字符串输出
[learning notes] subsets and questions
[從零開始學習FPGA編程-49]:視野篇 - 芯片是如何被設計出來的?
Troubleshooting of pyinstaller failed to pack pikepdf
Blog publishing test 2
CTFHub-Web-密码口令-默认口令
【学习笔记】子集和问题
Project R & D, what are the free brain mapping tools that are easy to use
Wechat campaign auto like
干货丨微服务架构是什么?有哪些优点和不足?