sys.path和os.path1.sys.path是python搜索模块的路径集合,是个list;os.path是os的一个模块,是操作文件和目录的模块2.sys.path和PYTHONPATH首先PYTHONPATH可以通过sys.path来查看可以通过sys.path.append(path)...
分类:
其他好文 时间:
2014-12-24 11:23:09
阅读次数:
143
os.path模块主要用于文件的属性获取,在编程中经常用到,以下是该模块的几种常用方法。>>> import os.path>>> path = '/home/ethon/doc/file.txt'>>> os.path.abspath(path) # 返回path规范化的绝对路径'C:\\h...
分类:
编程语言 时间:
2014-12-23 12:08:23
阅读次数:
163
如何从文件中读取300个汉字?看起来很简单,但很容易掉坑里了。一开始我这么写:1 try:2 fd = codecs.open(os.path.join(settings.TEXT_CONTENT_DIR,channel_name.lower(), article_id), ...
分类:
编程语言 时间:
2014-12-20 23:27:37
阅读次数:
356
import os dir = 'D:/hero/Classes'def readfile(dir): str="" first_line=1 for f in os.listdir(dir): file = os.path.join(dir, f) ...
分类:
移动开发 时间:
2014-12-20 11:33:29
阅读次数:
167
#coding=utf-8
?
from?ftplib?import?FTP
import?os
import?os.path
import?shutil
import?datetime
?
def?ftp_up(filename):
????ftp=FTP()?
????ftp.set_debuglevel(2)#打开调试级别2,显示...
分类:
编程语言 时间:
2014-12-16 19:35:19
阅读次数:
158
Python 2.7.8 该模块实现了一些关于路径名的函数。os.path.abspath(path) 返回所给参数的绝对路径。os.path.basename(path)Return the base name of pathnamepath. This is the second ele...
分类:
编程语言 时间:
2014-12-16 11:32:29
阅读次数:
333
pkgname_="***"version_="1.0"importsysimportosbasepath_=os.path.dirname(os.path.realpath(__file__))modulepath_=os.path.join(basepath_,"modules")custompath_=os.path.join(basepath_,"custom")configpath_=os.path.join(basepath_,"config")sys.path.append(os.path.jo..
分类:
其他好文 时间:
2014-12-12 17:04:06
阅读次数:
229
vipython_tab.py#!/usr/bin/envpythonimportsysimportreadlineimportrlcompleterimportatexitimportos#tabcompletionreadline.parse_and_bind(‘tab:complete‘)histfile=os.path.join(os.environ[‘HOME‘],‘.pythonhistory‘)try:readline.read_history_file(histfile)exceptIOErr..
分类:
编程语言 时间:
2014-12-08 19:46:44
阅读次数:
455
import tornado.httpserver
import tornado.ioloop
import tornado.web
import tornado.options
import os.path from tornado.options import define, options
d...
分类:
其他好文 时间:
2014-11-26 01:25:54
阅读次数:
217
#!/usr/bin/env python# -*-coding:utf-8 -*-__author__ = 'shylock'import sys,osimport ConfigParserdef is_dir(config_path): return os.path.isdir(confi...
分类:
编程语言 时间:
2014-11-24 23:59:59
阅读次数:
802