##python3 基础用法 输入字符串以空格分割
inp = input().split(" ")
str 转换 list
num = list(map(int,str.split(" "))) #利用map函数将以空格分割的str转换成list
list 转换 str
str = ','.join(list) #利用join函数将list 转换成以','分割的str
list 排序
a = [3,2,5]
a.sort()
print(a)
a = [2,3,5]
字典的使用
a=eval(input())
b=eval(input())
for key,value in b.items():
if key in a.keys():
a[key]=a[key]+value
else:
a[key]=value
print(a)
函数定义和调用
#使用seed函数随机生成密码
import string
from random import *
def fdj(num):
seed(num)
return choice(a)
a = list(string.printable)
x = int(input())
print(fdj(x))
#定义函数输出最大值和总和,单个函数传递多个值
def max_sum(str):
num = list(map(int,str.split(" "))) #将str转换成list 并且使用“ ” 做分割
max1 = 0
sum1 = 0
for i in range(len(num)):
sum1 = sum1 + num[i]
if num[i]>max1:
max1 = num[i]
pass
pass
return(max1,sum1)
x=input()
max1,sum1=max_sum(x)
print(max1)
print(sum1)
定义需要输入的行数
inp = int(input())
inp_list = []
for i in range (inp):
x = int(input())
inp_list.append(x)
print(inp_list)