Some of the use of Python to solve algorithmic problems

a = int(n) # 转换成int类型
a = list(map(int,input().split()))	# 输入数组为int类型
a.upper() # 大写
a.lower() # 小写
a.isalpha() # 判断是否为字母
#还有很多判断,如数字等等

print(out[i], end='')	# print不换行
print('hello {:.2f}  hei  {:.3f}'.format(a,b)) # 小数的输出
n = ord('A') # A的ASCII码
c = chr(97) # 把97转换成字符

a = 3, b = 2
c = a // b  # 整除

x.append() # 假设x是个list,append函数用来增加元素

out = [1,2,3]
print(*out) # 输出out数组中的元素,以空格隔开
print(max(out ),min(out )) # 输出数组中最大和最小的
out.reverse() # 反转out数组

a = "123"
a = a.rjust(4,'0') # 右对齐,向左填充0,直到4位
a = a.replace(old,new) # 把字符串a中的 old 用 new 来代替

Guess you like

Origin blog.csdn.net/qq_43567222/article/details/114758645