#python版本:3.5.2 #for循环 for letter in ("xuyingke"): #默认循环 print ("当前字母:",letter) array = ["h","ss","2ww"] #通过下标循环 for index in range(len(array)): print ("当前水果:",array[index]) #字符串截取: var = ("xuyingke") print ("==",var[5:8]) #从下标5截取到下标8 #字符串更新: var = ("xuyingke") print ("更新后的字符串",var[:3] + "添加的字符") #截取一部分,连接另一部分~ #字符串格式化: print ("my age is %d" % (23)) #结果为:my age is 23 这个和C语言是一样的~ #终止程序: import sys #导入 exit() #终止程序函数 #ps:另一种导入方法 from sys import exit #文件首部加上:from 库名 import 函数名 #打开图片文件: from os import popen os.popen("webwxgeticon.jpg")