1、Print函数中文编码问题
print中的编码:# -*- coding: utf-8 -*-
注:此处的#代表的是配置信息
print中的换行符,与C语言相同,为"\n"
2、数据结构List(列表)
# -*- coding: utf-8 -*- #创建List number_list = [1, 3, 5, 7, 9] string_list = ["abc", "bbc", "python"] mixed_list = ['python', 'java', 3, 12] #访问List中的值 second_num = number_list[1] third_string = string_list[2] fourth_mix = mixed_list[3] print("second_num: {0} third_string: {1} fourth_mix: {2}".format(second_num, third_string, fourth_mix)) #更新List print("number_list before: " + str(number_list)) number_list[1] = 30 print("number_list after: " + str(number_list)) #删除List元素 print("mixed_list before delete: " + str(mixed_list)) del mixed_list[2] print("mixed_list after delete: " + str(mixed_list)) #Python脚本语言 print(len([1,2,3])) #长度 print([1,2,3] + [4,5,6]) #组合 print(['Hello'] * 4) #重复 print(3 in [1,2,3]) #某元素是否在列表中 #List的截取 abcd_list =['a', 'b', 'c', 'd'] print(abcd_list[1]) print(abcd_list[-2]) print(abcd_list[1:]) print(abcd_list[-2:])