1、dic_name = {‘name’ = ‘tom’,’age’=27,’sex’=’男’},请使用for循环依次从里面取出对应的value
dic_name = {“name”:“tom”,“age”:27,“sex”:“男”}
#方法1
for i in dic_name.values():
print(i)
#方法2
for key in dic_name:
print(dic_name.get(key))
#方法3
for key,val in dic_name.items():
print(val)
2、“人生苦短,我用Python!”,请用切片的方式取出Python字段
a = “人生苦短,我用Python!”
print(a[7:13])
3、“人生苦短,我用Python!”,请用“,”分隔此字符串
a=“人生苦短,我用Python!”
print(a.split(","),len(a.split(",")))
print(a.split(sep=","))