python之函数用法execfile()
# -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法execfile() #execfile() #说明:用来执行一个文件,相对于双击的效果 ''' execfile(...) execfile(filename[, globals[, locals]]) filename:文件名 globals:全局变量--这里指绝对路径 locals:本地变量--这里指相对路径 Read and execute a Python script from a file. The globals and locals are dictionaries, defaulting to the current globals and locals. If only globals is given, locals defaults to it. ''' #案例 #import chardet filename=r'my.py' #print chardet.detect(filename)#ascii #filename=r'my.py'.decode('ascii') execfile(filename)
无语言基础,自学python所做的各种笔记,欢迎大牛指点.