04 2018 档案
摘要:#字符串替换import sysf = open("yesterday2","r",encoding="utf-8")f_new = open("yesterday2.bak","w",encoding="utf-8")find_str = sys.argv[1]replace_str = sys.
阅读全文
摘要:#w写模式,r读模式,a追加,r+读写,w+写读,a+追加读,rb二级制格式读文件,wb写二级制文件 '''f = open('yesterday','a+',encoding='utf-8') #文件句柄(文件内存对象): f = open('yesterday','r+',encoding='u
阅读全文
摘要:#集合是无序的list_1 = [1,3,4,5,7,3,6,7,9]list_1 = set(list_1) #集合去重list_2 = set([2,6,0,66,22,8,4])#交集print(list_1.intersection(list_2))#并集print(list_1.union
阅读全文
摘要:name = 'my name is {name} and i am {year} old'print(name.capitalize()) #首字母:My name alexprint(name.count("a")) #统计a :2print(name.center(50,"-")) #补足50
阅读全文
摘要:1、浅COPY,如果源变化,p1[1][1]、p2[1][1]、person[1][1]会一起变化 import copyperson = ['name',['saving',100]]'''p1 = copy.copy(person)p2 = person[:]p3 = list(person)'
阅读全文
摘要:product_list = [ ('IPhone',5800), ('Mac Pro',12000), ('Starbuck Latte',31), ('Alex Python',81), ('Bike',800)]shopping_list = []salary = input('Input y
阅读全文
摘要:#decoding转为字符串:解码;encode转为二进制:转码msg = "我爱北京天安门"print(msg.encode()) #encode默认utf-8print(msg.encode(encoding="utf-8").decode(encoding="utf-8"))
阅读全文
摘要:sys.path的输出: ['C:\\Users\\Administrator\\PycharmProjects\\S14\\Day2' 'C:\\Users\\Administrator\\PycharmProjects\\S14' 'C:\\Program Files\\Python36\\py
阅读全文
摘要:import getpass_username = 'wu'_password = 'wu123'username = input("username:")#password = getpass.getpass("password:") #密文输入password = input("password
阅读全文
摘要:1、基础参数定义实例print("hello world")name = "PaoChe Ge"name2 = nameduohang = '''print("My name is",name)name = "Mr Li"print(name2,"and",name)'''print(duohang
阅读全文

浙公网安备 33010602011771号