Python教程

Python教程:包含了所有代写案例以及部分答案

  • #coding: UTF-8 def arrage(temp_list): num = len(temp_list) for i in range(1,num): for j in range(i): if temp_list[i] >= temp_list[j] and j == (i-1): break elif temp_list[i] <= temp_list[j] and j == 0: temp_list.insert(0,temp_list.pop(i)) elif t … 继续阅读“python实现插入排序”

    :
  • # 9*9 for i in list(range(1,10)): for j in list(range(1,10)): if i >= j: print(i * j, ”, end=”); else: print("\n"); break; 标签:python

    :
  • 目前处在学习python的阶段,昨天看到了python的socket模块,分别实现TCP、UDP时间戳回显。 1、tcp通信server和client代码 # tcpServer.py #!/usr/bin/python # -*- coding: utf-8 -*- from socket import * from time import ctime HOST = ” PORT = 21156 BUFSIZE = 1024 ADDR = (HOST,PORT) tcpServerSock … 继续阅读“Python的socket编程”

    :
  • from graphics import * from math import * def gobangwin(): win=GraphWin("this is a gobang game",400,400) #ÖÆ×÷21×21µÄÆåÅÌ win.setBackground("yellow") i1=0 while i1<401: l=Line(Point(i1,0),Point(i1,400)) l.draw(win) i1=i1+20 i2= … 继续阅读“python 五子棋”

    :
  • #!/usr/bin/env python # -*- coding:utf-8 -*- from gevent import monkey monkey.patch_all() from gevent.pool import Pool import requests import sys import os def download(url): chrome = ‘Mozilla/5.0 (X11; Linux i86_64) AppleWebKit/537.36 ‘ + \ ‘(KHTML, … 继续阅读“python 批量下载文件”

    :
  • #水仙花数 #narcissistic number #水仙花数是指一个 n 位数 ( n≥3 ),它的每个位上的数字的 n 次幂之和等于它本身。 #(例如:1^3 + 5^3+ 3^3 = 153) import math import string for x in range(1,10): a=x*x*x for y in range(0,10): b=y*y*y for z in range(0,10): c=z*z*z d=a+b+c w=’%d’ %x+’%d’ %y+’%d’ %z … 继续阅读“python 水仙花数”

    :