This work shows that mesoporous polymeric films with spherical and elliptical pores can be obtained by in situ structure inversion of the azo polymer colloid arrays through selective interaction with solvent. The epoxy-based azo polymer contained both the pseudo-stilbene-type azo chromophores and the hydrophilic carboxyl groups. The colloidal spheres of the azo polymer were prepared by gradual hydrophobic aggregation of the polymeric chains in THF-H2O media, induced by a steady increase in the water content. Ordered 2D arrays of the hexagonally close-packed colloidal spheres were obtained by the vertical deposition method. After the solvent (THF) annealing, the ordered 2D arrays were directly transformed to mesoporous films through the sphere-pore inversion. Under the same condition, the 2D arrays composed of the ellipsoidal colloids, which were obtained by the irradiation of a polarized Ar+ laser beam on the colloidal sphere arrays, could be transformed to films with ordered elliptical pores. To our knowledge, this is the first example to demonstrate that mesoporous structures can be directly formed from the colloidal arrays of a homopolymer through structure inversion. This observation can shed new light on the nature of self-assembly processes and provide a feasible approach to fabricate mesoporous structures without the infiltration-removal step. By exploring the photoresponsive properties of the materials, mesoporous film with special pore structure and properties can be expected.