def test(): helper.dividing_with_title(' start ') # repr import repr print repr.repr(set('abcdedabc')) print repr.repr(dict({'name': 'wjh', 'age': 11})) # pprint import pprint t = [[[['black', 'cyan'], 'white', ['green', 'red']], [['magenta', 'yellow'], 'blue']]] pprint.pprint(t, None, 1, 80) # textwrap import textwrap doc = """The wrap() method is just like fill() except that it returns a list of strings instead of one big string with newlines to separate the wrapped lines.""" print textwrap.fill(doc, 50) # locale import locale locale.setlocale(locale.LC_ALL, 'English_United States.1252') conv = locale.localeconv() x = 1234.6 print locale.format("%d", x, grouping=True) print locale.format_string( "%s%.*f", (conv['currency_symbol'], conv['frac_digits'], x), grouping=True) # Template from string import Template t = Template('${village}folk send $$10 to $cause.') print t.substitute(village='Nottingham', cause='the ditch fund') d = dict(name='wjh', age=20) t = Template('name: $name and age: $age') print t.substitute(d) print t.safe_substitute(d) import time, os.path photofiles = ['img_1074.jpg', 'img_1076.jpg', 'img_1077.jpg'] # fmt = raw_input('Enter rename style (%d-date %n-seqnum %f-format): ') # print fmt # struct import struct data = open(helper.getfile('test.txt'), 'rb') print data.readline() data.close()
def test(): helper.dividing_with_title(' start ') # repr import repr print repr.repr(set('abcdedabc')) print repr.repr(dict({'name' : 'wjh', 'age' : 11})) # pprint import pprint t = [[[['black', 'cyan'], 'white', ['green', 'red']], [['magenta', 'yellow'], 'blue']]] pprint.pprint(t,None,1,80) # textwrap import textwrap doc = """The wrap() method is just like fill() except that it returns a list of strings instead of one big string with newlines to separate the wrapped lines.""" print textwrap.fill(doc,50) # locale import locale locale.setlocale(locale.LC_ALL,'English_United States.1252') conv=locale.localeconv() x = 1234.6 print locale.format("%d", x, grouping=True) print locale.format_string("%s%.*f", (conv['currency_symbol'], conv['frac_digits'], x), grouping=True) # Template from string import Template t = Template('${village}folk send $$10 to $cause.') print t.substitute(village='Nottingham', cause='the ditch fund') d = dict(name='wjh',age=20) t = Template('name: $name and age: $age') print t.substitute(d) print t.safe_substitute(d) import time, os.path photofiles = ['img_1074.jpg', 'img_1076.jpg', 'img_1077.jpg'] # fmt = raw_input('Enter rename style (%d-date %n-seqnum %f-format): ') # print fmt # struct import struct data = open(helper.getfile('test.txt'), 'rb') print data.readline() data.close()
# file: # coding:utf-8 __author__ = 'robin' import json import cn.net.vive.base.helper as helper table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678} filename = helper.getfile("test.txt") def test(): # 查看 json # print json.dumps(table) # 导出json # dumpfile() # 加载json # loadfile() # 读取文件 # readfile2() # with 方式 testwith() def testwith():