1. Szinput = input ("<<<") #只能输入字符串
2. ninput = Int (szinput) #字符串转换成数字3. While else
Continue #终止当前循环
Break #终止循环
4. and #条件与
5. Pycharm Installation and Setup
Font: 28 line number Mouse changes font size: Mouse->editor->general->change font size (Zoom) with ctrl+mouse Wheel Template: Editor->code styl E->file and Code Templates->file->python script
#coding =utf-8
#Version:p ython3.6.0
#Tools:P ycharm 2017.3.2
_date_ = ' $DATE $TIME '
_author_= ' Mafucun '
6. Substring
#子序列, substring
SzName = "Mafucun"
If "Ma" in SzName:
print (' OK ')
else:
print (' Error ')
7. Ctrl +? #快速注释语句
8. In/not in# Determines whether a member operates in a string
9. Boolean value True, False
10. Comparison operators: = = =, ",", >=, <=,!=, <>
It is recommended to use parentheses True or ==>true False and ==>false other needs to continue to judge 11. Basic Data type characteristics
number int string str list Group tuple dictionary Dict boolean value bool 12. CTRL + Left key, data type characteristics
13. Digital
Int () #将字符串转换为数字
Type () #显示变量类型
num = 123
v = num.bit_length ()
print (v)
14. String
Name = "Shizhengwen"
v1 = name.upper ()
print (v1)
szstring = "123"
print (Type (szstring), szstring)
szString2 = "0b11" #二进制
szString3 = "0011" #二进制
nint = Int (szString3, base = 2) #将2进制的数值转换为10进制
nage = 10
nlength = Nage.bit_length () #数值的二进制位数
print (nlength)