数据类型作业:
# 练习一:把 'hello xiao mi' 变成 'mi xiao hello' a = 'hello xiao mi' temp = a.split(' ') print(' '.join(temp[::-1])) # 练习三:把 yuyan = ['python', 'java', 'php'] 拼接成一个字符串,然后将所有字母转换成大写 yuyan = ['python', 'java', 'php'] temp = '_'.join(yuyan) print(temp.upper()) # 练习四:t1 = ("aa", 11) t2 = ('bb', 22) t3 = [("cc", 11)] # 把上面3个变成: {"aa": 11, "cc": 11, "bb": 22} t1 = ("aa", 11) t2 = ('bb', 22) t3 = [("cc", 11)] t = {} t[t1[0]] = t1[1] t[t3[0][0]] = t3[0][1] t[t2[0]] = t2[1] print(t) # 练习二: name = input('请输入您的姓名:') gender = input('请输入您的性别:') age = input('请输入您的年龄:') p_info = {} p_info['name'] = name p_info['gender'] = gender p_info['age'] = age print('我的名字是{0},今年{1}岁,性别{2},喜欢敲代码'.format(p_info['name'], p_info['age'], p_info['gender'])) height = input('请输入您的身高:') tel = input('请输入您的电话:') p_info['height'] = height p_info['tel'] = tel print(p_info) p_info.pop('tel') print(p_info) specialty = input('请输入您的特长:') p_info['specialty'] = specialty print(p_info)View Code
执行结果如下:
D:\SkyWorkSpace\WorkSpace\Pytest\Temp\day06\venv\Scripts\python.exe D:/SkyWorkSpace/WorkSpace/Pytest/Temp/day06/gggg/test_2.py mi xiao hello PYTHON_JAVA_PHP {'aa': 11, 'cc': 11, 'bb': 22} 请输入您的姓名:sky 请输入您的性别:男 请输入您的年龄:25 我的名字是sky,今年25岁,性别男,喜欢敲代码 请输入您的身高:175 请输入您的电话:153534534 {'name': 'sky', 'gender': '男', 'age': '25', 'height': '175', 'tel': '153534534'} {'name': 'sky', 'gender': '男', 'age': '25', 'height': '175'} 请输入您的特长:游泳 {'name': 'sky', 'gender': '男', 'age': '25', 'height': '175', 'specialty': '游泳'} Process finished with exit code 0View Code
debug调试
1、设置断点,一般设置在 能显示所有变量值的地方
2、运行调试,能看到过程中 变量值的变化。 F7 进入方法,F8 不进入方法 ;