The next content

1. how the digital input strings into numbers:

inp = input ( 'Enter number :)

num—inp=int(inp)

2.whie which can have else: it can only be performed while loop executes repeatedly else to meet again

Copy the code
count=0
while count <10:
    print(count)
    count+=1
else :
    print('测试成功')
Copy the code

3.while Lane continue: If you encounter continue in the loop will not continue with the next block of code, but conditional jump directly for the next cycle. That is out of the next iteration of this cycle:

Copy the code
while count<10:
    count=count+1
    print(count)
    continue
    print(111111)
print('end')
Copy the code

while inside if there is a break statement to terminate the cycle directly following procedures: general and break and if used in conjunction

 

Are 4.in sentenced segment belongs to a subset of belonging to True if the string is returned otherwise return False; not in the opposite

name = 'text document' 
IF 'evidence' in name: 
     Print ( 'the ok') 
elif 'Jianwen' not in name: 
    Print ( 'error')

Methods 5.pycharm overall comment is: Select what you want to comment and then hold down ctrl +?

6. Data type Boolean ·: False and True

7.比较运算:> <  ==   !=

8.逻辑运算:and  or not  在进行逻辑运算时,如果and前为假则无需判断直接输出false 如果or 前面是真则无需进行,输出结果时true

9.基本的数据类型:数字,布尔型、字符型、列表、元组、字典

10.int类型下可以进行的操作:第一个是将想要的进制放入base中然后转化为十进制数,第二个程序是看十进制数转化为二进制数共有多少位

num='19933'
v=int (num,base=16)
print(v)
age=12
v=age.bit_length()
print(v)

11.字符串前几个类型: 第一个将字母的开头字母进行大写 ,第二个是单词的所有进行小写,第三个也是,第四个是把单词放到中央如果不写file则默认空格而且所添加的字符只能是一个:

test='aleldl'
test.capitalize()
test.casefold()
test.lower()
test.center()

12.字符串的类型:第一个数所查询字符在字符串中出现的次数,第二个和第三个分别为判断字符串的开头和结尾如果不是则返回false ,第四个是寻找字符串的索引号,

test='aleldl'
test.count()
test.endswith()
test.startswith()
test.find()
Copy the code
test='i am {0},age{1}'
test.format('lex',21)
print(test)
test1='i am {name}'
test1.format(name='alex')
print(test1)
Copy the code

13.format-map which is added to the dictionary function and format is the same as

Guess you like

Origin www.cnblogs.com/ab461087603/p/11823346.html