Python教程

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

  • from os.path import basename, isdir from os import listdir def traverse(path, depth=0): print depth* ‘| ‘ + ‘|_’, basename(path) if(isdir(path)): for item in listdir(path): traverse(path+’/’+item, depth+1) if __name__ == ‘__main__’: traverse(‘./’) 标签 … 继续阅读“python遍历目录树代码”

    :
  • import socket, traceback host = ” port = 51423 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind((host, port)) while 1: try: message, address = s.recvfrom(8192) print ‘Got data from’, … 继续阅读“python udp 服务器”

    :