• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python string.center函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中string.center函数的典型用法代码示例。如果您正苦于以下问题:Python center函数的具体用法?Python center怎么用?Python center使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了center函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_playerOrder

def get_playerOrder(players, playerOrder_val):
    playerOrder = [0, 0, 0]
    print "We will now play the Toss-Up Spin for possession of The Wheel in the first"
    print "round."
    print string.center(("-" * 80), 80)
    raw_input ("Press 'ENTER' to continue: ")
    for i in (0, 1, 2):
        if i == 0:
            print players[i] + " will spin first."
        print "Get ready! " + players[i] + " is up next."
        print "It is " + players[i] + "'s turn to spin."
##        print string.center(("-" * 80), 80)
        raw_input("Press 'ENTER' to spin The Wheel. ")
        print string.center(("-" * 80), 80)
        print string.center((players[i] + " received $" + str(i * 100) + "."), 80)
        print string.center(("-" * 80), 80)
        for j in (0, 1):
            if j == 0:
                playerOrder_val[i][j] = (i * 100)
            else:
                playerOrder_val[i][j] = players[i]
    playerOrder_val.sort(reverse=True)
    for i in range(3):
        playerOrder[i] = playerOrder_val[i][1]
    print "Congratulations,", playerOrder[0] + "! You have won the Toss-Up Spin and will take possession"
    print "of The Wheel at the beginning of the first round."
    print ""
    print playerOrder[1] + " will Take possession of The Wheel after", playerOrder[0] + ", followed by", playerOrder[2] + "."
    print string.center(("-" * 80), 80)
    raw_input ("Press 'ENTER' to continue: ")
    return playerOrder
开发者ID:churchie317,项目名称:wheel_of_fortune,代码行数:31,代码来源:Wheel_of_Fortune_v1.py


示例2: load_edbfile

def load_edbfile(file=None):
    """Load the targets from a file"""
    import ephem,string,math
    if file is None:
        import tkFileDialog
	try:
            file=tkFileDialog.askopenfilename()
        except:
            return 
    if file is None or file == '':
        return
    f=open(file)
    lines=f.readlines()
    f.close()
    for line in lines:
        p=line.split(',')
	name=p[0].strip().upper()
	mpc_objs[name]=ephem.readdb(line)
	mpc_objs[name].compute()
        objInfoDict[name]="%6s %6s %6s\n" % ( string.center("a",6),
				            string.center("e",6),
	 				    string.center("i",6) ) 
        objInfoDict[name]+="%6.2f %6.3f %6.2f\n" % (mpc_objs[name]._a,mpc_objs[name]._e,math.degrees(mpc_objs[name]._inc))
        objInfoDict[name]+="%7.2f %7.2f\n" % ( mpc_objs[name].earth_distance, mpc_objs[name].mag)
    doplot(mpc_objs)
开发者ID:OSSOS,项目名称:MOP,代码行数:25,代码来源:MOPplot.py


示例3: convert1

	def convert1(self, strIn):
		"Convert Unicode strIn to PinYin"
		length, strOutKey, strOutValue, i=len(strIn), "", "", 0
		while i<length:
			code1 =ord(strIn[i:i+1])
			if code1>=0x4e02 and code1<=0xe863:
				strTemp   = self.getIndex(strIn[i:i+1])
				if not self.has_shengdiao:
					strTemp  = strTemp[:-1]
				strLength = len(strTemp)
				if strLength<1:strLength=1
				strOutKey   += string.center(strIn[i:i+1], strLength)+" "
				strOutValue += self.spliter + string.center(strTemp, strLength) + self.spliter
			else:#ascii code;
				strOutKey+=strIn[i:i+1]+" "
				strOutValue+=strIn[i:i+1] + ' '
			i+=1
			#############################
			#txlist = utf8String.split()
			#out=convert.convert(utf8String)
			#l=[]
			#for t in map(convert.convert, txlist):
			#	l.append(t[0])
			#v = '-'.join(l).replace(' ','').replace(u'--','-').strip('-')
			#############################
		return [strOutValue, strOutKey]
开发者ID:3c7,项目名称:seahub,代码行数:26,代码来源:cconvert.py


示例4: writerow

 def writerow(self, row, sep=None, *args, **kwargs):
     """
     Write General Data row to file
     """
     if not self.has_header:  # Write basic header for raw data
         self.file.write(self.encode.write_header() + '\n')
         self.has_header = True
     if sep is None:
         sep = self.default_sep
     if sep not in [',', ';', '|', ':']:
         raise AdtmError('Invalid Row Value Seperator ("{0:s}") provided, '
                         'must be ( "," | ";" | "|" | ":" )'.format(sep))
     self.offset += 1
     if self.offset - self.last_headerrow == 5*5:
         self.file.write("#" + sep.join((string.center(h, w) for h, w in
                                         izip_longest(self.headers,
                                                      self.col_width,
                                                      fillvalue=0)))[1:]
                         + "\n")
         self.last_headerrow = self.offset
         self.last_seprow = self.offset
         self.offset += 1
     elif self.offset - self.last_seprow == 5:
         self.file.write("#" + sep.join((string.center(" ", w) for w in
                                         self.col_width))[1:]
                         + "\n")
         self.last_seprow = self.offset
         self.offset += 1
     self.file.write(sep.join((string.center(self.encode(i), w) for i, w in
                               izip_longest(row,
                                            self.col_width,
                                            fillvalue=0)))
                     + "\n")
开发者ID:alphaomega-technology,项目名称:ADTM,代码行数:33,代码来源:_io.py


示例5: output_result

def output_result(results, file):
    # file output
    filename, file_size = file
    filename = ljust(filename[:19], 19)
    file_size = get_string_size(file_size)
    file_size = rjust(file_size[:9], 9)
    file_string = u'%s  %s' % (filename, file_size)

    parser_output = u''
    # output 1
    parser_name, result = results[0]
    if result is None:
        output1 = center(u'FAILED',  21)
    else:
        time_spent, memory = result
        memory = get_string_size(memory)
        # time_spent ok already like ___.___ ms or s or mn
        output1 = rjust(u'%s / %s' % (time_spent, memory), 21)

    # output 2
    parser_name, result = results[1]
    if result is None:
        output2 = center(u'FAILED',  21)
    else:
        time_spent, memory = result
        memory = get_string_size(memory)
        # time_spent ok already like ___.___ ms or s or mn
        output2 = rjust(u'%s / %s' % (time_spent, memory), 21)

    print '%s | %s | %s ' % (file_string, output1, output2)
开发者ID:kennym,项目名称:itools,代码行数:30,代码来源:bench_xml.py


示例6: output_success

def output_success():
    # print information about success matches

    if opts.summary or opts.verbose:
        print "\n ------------------------------------------------------------------------------"
        print string.center(">>>>> Successful matches <<<<<", 80)
        print " ------------------------------------------------------------------------------"
        s_success = sorted(success, key=lambda k: k['name']) # group by site name
        # print normal summary table on request (--summary)
        if not opts.verbose and opts.summary:
            print "\n ------------------------------------------------------------------------------"
            print " ", "| Module |".ljust(35), "| Account |".ljust(28)
            print " ------------------------------------------------------------------------------"
            for s in s_success:
                print "  " + s['name'].ljust(37) + s['account'].ljust(30)
            print " ------------------------------------------------------------------------------\n"
        # print verbose summary on request (-v --summary)
        elif opts.verbose and opts.summary:
            for s in s_success:
                print textwrap.fill((" NAME: \t\t\t%s" % s['name']),
                    initial_indent='', subsequent_indent='\t -> ', width=80)
                print textwrap.fill((" ACCOUNT: \t\t%s" % s['account']),
                    initial_indent='', subsequent_indent='\t -> ', width=80)
                print textwrap.fill((" URL: \t\t\t%s" % s['url']),
                    initial_indent='', subsequent_indent='\t -> ', width=80)
                print textwrap.fill((" METHOD: \t\t%s" % s['method']),
                    initial_indent='', subsequent_indent='\t -> ', width=80)
                print textwrap.fill((" POST PARAMETERS: \t%s" % s['postParameters']),
                    initial_indent='', subsequent_indent='\t -> ', width=80)
                print " ------------------------------------------------------------------------------"
    else:
        print " ------------------------------------------------------------------------------\n"
开发者ID:marcwickenden,项目名称:Scythe,代码行数:32,代码来源:scythe.py


示例7: createSecMarkerReport

def createSecMarkerReport ():
    global annot, nonfatalCount, nonfatalReportNames

    print 'Create the secondary marker report'
    sys.stdout.flush()
    fpSecMrkRpt.write(string.center('Secondary Marker Report',130) + NL)
    fpSecMrkRpt.write(string.center('(' + timestamp + ')',130) + 2*NL)
    fpSecMrkRpt.write('%-20s  %-16s  %-50s  %-16s%s' %
                     ('Term ID', 'Secondary MGI ID',
                      'Marker Symbol','Primary MGI ID',NL))
    fpSecMrkRpt.write(20*'-' + '  ' + 16*'-' + '  ' + \
                      50*'-' + '  ' + 16*'-' + NL)

    cmds = []

    #
    # Find any MGI IDs from the input data that are secondary IDs
    # for a marker.
    #
    cmds.append('''
    	select tmp.termID, 
               tmp.mgiID, 
               m.symbol, 
               a2.accID 
        from %s tmp, 
                     ACC_Accession a1, 
                     ACC_Accession a2, 
                     MRK_Marker m 
        where tmp.mgiID is not null and 
                      lower(tmp.mgiID) = lower(a1.accID) and 
                      a1._MGIType_key = 2 and 
                      a1._LogicalDB_key = 1 and 
                      a1.preferred = 0 and 
                      a1._Object_key = a2._Object_key and 
                      a2._MGIType_key = 2 and 
                      a2._LogicalDB_key = 1 and 
                      a2.preferred = 1 and 
                      a2._Object_key = m._Marker_key 
        order by lower(tmp.mgiID), lower(tmp.termID)
	''' % (tempTable))

    results = db.sql(cmds,'auto')

    #
    # Write the records to the report.
    #
    for r in results[0]:
        termID = r['termID']
        mgiID = r['mgiID']

        fpSecMrkRpt.write('%-20s  %-16s  %-50s  %-16s%s' %
            (termID, mgiID, r['symbol'], r['accID'], NL))

    numErrors = len(results[0])
    fpSecMrkRpt.write(NL + 'Number of Rows: ' + str(numErrors) + NL)
    if numErrors > 0:
        if not secMrkRptFile in nonfatalReportNames:
            nonfatalReportNames.append(secMrkRptFile + NL)
    nonfatalCount += numErrors
开发者ID:mgijax,项目名称:mcvload,代码行数:59,代码来源:mcvQC.py


示例8: title

 def title(self,title):
     _l = len(title)
     _p = max(_l%2 +_l,40)
     _x = self.parlen -_p
     if (_x > 2):
         print (_x/2)*self.sep + string.center(title,_p) + (_x/2)*self.sep
     else:
         print string.center(text,self.parlen)
开发者ID:olivierch,项目名称:openBarter,代码行数:8,代码来源:utilt.py


示例9: lose_a_turn

def lose_a_turn(player_turn, playerOrder):
    
    print ""
    print playerOrder[player_turn], "spun for LOSE A TURN!"
    print ""
    print "Sorry, " + playerOrder[player_turn] + ". Possession of The Wheel passes to " + playerOrder[(player_turn + 1) % 3] + "."
    print string.center(("-" * 80), 80)
    time.sleep(2.5)
开发者ID:churchie317,项目名称:wheel_of_fortune,代码行数:8,代码来源:wheel_of_fortune.py


示例10: print_instruments

def print_instruments():
	"""Prints a display of all instruments by category and family"""

	for title, category in instruments.iteritems():
		print "\n" + string.center(" " + title + " ", 50, "~")
		for name, family in category.iteritems():
			print "\n" + string.center(" " + name + " ", 50, "-") + "\n"
			print_instrument_family(family)
开发者ID:jordanrossdunn,项目名称:pierrot,代码行数:8,代码来源:instruments.py


示例11: slove

def slove(C,I,P,N):
	fout=open("fout.out","w")
	for i in range(N):
		for j in range(I[i]-1):
			for k in range(j+1,I[i]):
				if P[i][j]+P[i][k]==C[i]:
					# print P[i][j],P[i][k],C[i]
					fout.write(str("Case #"+str(i+1)+":"+string.center(str(j+1),3)+" "+string.center(str(k+1),2)+"\r"))
					continue
开发者ID:repstd,项目名称:algorithm,代码行数:9,代码来源:StoreCredit.py


示例12: printGrid

	def printGrid(self):
		system("clear")
		print "_"*self.rowsize
		for i in range(self.size):
			print "|",
			for j in range(self.size):
				print center(str(self.grid[i][j]),self.cellwidth)+"|",
			print "\n"+"_"*self.rowsize
		print "Score: ",self.score
开发者ID:rakeshgariganti,项目名称:Py2048,代码行数:9,代码来源:py2048.py


示例13: guess_previously_called

def guess_previously_called(player_turn, playerOrder, guess):
    print ""
    print "Sorry, '" + guess + "' has already been called in this round."
    print playerOrder[(player_turn + 1) % 3] + " now takes possession of The Wheel."
    print ""
    print string.center(("-" * 80), 80)
    time.sleep(1.5)

    return playerOrder
开发者ID:churchie317,项目名称:wheel_of_fortune,代码行数:9,代码来源:wheel_of_fortune.py


示例14: draw_grid

def draw_grid(
    screen, questions,
    selected_question, answered_questions,
    player_scores ):
    height, width = screen.getmaxyx()

    columns = len(questions)
    rows = len(questions[0]["questions"])

    # take the total screen width, subtract the border zone,
    # and allow INNER_GRID_BORDER space between each column
    category_width = ( width-GRID_HORIZ_BORDER*2-
                       (columns-1)*INNER_GRID_BORDER ) // columns

    question_grid_start = GRID_VERT_OFFSET + SPACE_FROM_CATEGORY_TO_LEVELS

    for i, category in enumerate(questions):
        category_name = (category["name"]
                         if len(category["name"]) <= category_width
                         else category["abrev_name"][:category_width]
                         )[:category_width]

        horizontal_position = (
            GRID_HORIZ_BORDER + i*category_width +
            i*INNER_GRID_BORDER
            )

        screen.addstr(
            GRID_VERT_OFFSET,
            horizontal_position,
            center(category_name, category_width, " "),
            CURSES_COLOUR_PAIR_GOOD_FEEL
            )

        for j, score in enumerate(POINTS):
            cur_color = CURSES_COLOUR_PAIR_GOOD_FEEL
            if (i, score) == tuple(selected_question):
                if (i, score) in answered_questions:
                    cur_color = CURSES_COLOUR_PAIR_MEH
                else:
                    cur_color = CURSES_COLOUR_PAIR_REALLY_GOOD
            elif (i, score) in answered_questions:
                cur_color = CURSES_COLOUR_PAIR_BAD_FEEL

            screen.addstr(
                question_grid_start + j+j*VERT_INNER_GRID_BORDER,
                horizontal_position,
                center(str(score), category_width, " "),
                cur_color )
    
    player_scores_str = PLAYER_SEP_CHARS.join(player_scores)
    player_scores_str = \
        player_scores_str[:(width-GRID_PLAYER_SCORES_HORIZ_OFFSET)]
    screen.addstr(height-2, GRID_PLAYER_SCORES_HORIZ_OFFSET,
                  player_scores_str,
                  CURSES_COLOUR_PAIR_MAX_CONTRAST )
开发者ID:skullspace,项目名称:hacker-jeopardy,代码行数:56,代码来源:curses_drawing.py


示例15: writeInvcoordStrandHeader

def writeInvcoordStrandHeader():
    print 'Create the invalid coordinate and strand report'
    fpInvCoordStrandRpt.write(string.center('Invalid Coordinate and Strand Report',110) + NL)
    fpInvCoordStrandRpt.write(string.center('(' + timestamp + ')',110) + 2*NL)
    fpInvCoordStrandRpt.write('%-12s  %-20s  %-20s  %-10s  %-20s  %-30s%s' %
                     ('MGI ID','Start Coordinate','End Coordinate', 'Strand',
                      'Provider','Reason',NL))
    fpInvCoordStrandRpt.write(12*'-' + '  ' + 20*'-' + '  ' + 20*'-' + '  ' + \
                      10*'-' + '  ' + 20*'-' + '  ' + 30*'-' + NL)
    return
开发者ID:mgijax,项目名称:mrkcoordload,代码行数:10,代码来源:mrkcoordQC.py


示例16: output_accounts

def output_accounts():
    # print information about the accounts loaded from accountfile

    print "\n ------------------------------------------------------------------------------"
    print string.center(">>>>> Accounts Loaded <<<<<", 80)
    print " ------------------------------------------------------------------------------"
    for a in accounts:
        print textwrap.fill((" Account name: %s" % a),
            initial_indent='', subsequent_indent=' -> ', width=80)
    print " ------------------------------------------------------------------------------\n"
开发者ID:marcwickenden,项目名称:Scythe,代码行数:10,代码来源:scythe.py


示例17: bankrupt

def bankrupt(player_turn, playerOrder, playerOrder_val_round):

    print ""
    print playerOrder[player_turn], "spun for BANKRUPT, bringing his total prize for this round to $0."
    playerOrder_val_round[player_turn][0] = 0
    print "Possession of The Wheel passes to", playerOrder[((player_turn + 1) % 3)] + "."
    print ""
    print string.center(("-" * 80), 80)
    time.sleep(2.5)

    return playerOrder_val_round
开发者ID:churchie317,项目名称:wheel_of_fortune,代码行数:11,代码来源:wheel_of_fortune.py


示例18: test_TypeError

	def test_TypeError(self):
		#Given
		s = 'abc'
		width = 7
		list_fillchar = ['', 'ab']
		
		for fillch in list_fillchar:
			#Then
			with  self.assertRaises(TypeError):
				#When
				string.center(s, width, fillch)
开发者ID:veronikam,项目名称:aspp_d1,代码行数:11,代码来源:test_center.py


示例19: show

 def show(self):  # proc
    if self.name: print lj(self.name, 12),
    else: print center('-', 12),
    if self.surname: print lj(self.surname, 12),
    else: print center('-', 12),
    if self.job: print lj(self.job, 12),
    else: print center('-', 12),
    if self.dest: print lj(self.dest, 12),
    else: print center('-', 12),
    if self.sport: print lj(self.sport, 12)
    else: print center('-', 12)
开发者ID:asottile,项目名称:ancient-pythons,代码行数:11,代码来源:Commuter.py


示例20: get_playerOrder

def get_playerOrder(players, playerOrder_val):
    playerOrder = []
    print "We will now play the Toss-Up Puzzle for possession of The Wheel in the first"
    print "round."
    print ""
    print players[0] + " will spin first."
    print ""
    print string.center(("-" * 80), 80)
    raw_input ("Press 'ENTER' to continue: ")
    for i in (0, 1, 2):
        print ""
        print players[i] + ", get ready. You're up next!"
        print players[i] + " prepares to spin The Wheel."
        print ""
        raw_input("Press 'ENTER' to spin The Wheel. ")
        print ""
        prize = prize = get_prize(0)
        print string.center(("-" * 80), 80)
        print string.center((players[i] + " received $" + str(prize) + "."), 80)
        print string.center(("-" * 80), 80)
        for j in (0, 1):
            if j == 0:
                playerOrder_val[i][j] = prize
            else:
                playerOrder_val[i][j] = players[i]
    playerOrder_val.sort(reverse=True)
    for i in range(3):
        if i == 0:
            playerOrder.insert(0, playerOrder_val[i][1])
        else:
            if i == 1:
                if playerOrder_val[i][0] > playerOrder_val[0][0]:
                    playerOrder.insert(0, playerOrder_val[i][1])
                else:
                    playerOrder.insert(1, playerOrder_val[i][1])
            else:
                if playerOrder_val[i][0] > playerOrder_val[0][0] and playerOrder_val[1][0]:
                    playerOrder.insert(0, playerOrder_val[i][1])
                elif playerOrder_val[i][0] < playerOrder_val[0][0] and playerOrder_val[1][0]:
                    playerOrder.insert(2, playerOrder_val[i][1])
                else:
                    playerOrder.insert(1, playerOrder_val[i][1])
    print ""
    print "Congratulations,", playerOrder[0] + "! You have won the Toss-Up Spin and will take possession"
    print "of The Wheel at the beginning of the first round."
    print ""
    print playerOrder[1] + " will Take possession of The Wheel after", playerOrder[0] + ", followed by", playerOrder[2] + "."
    print ""
    print string.center(("-" * 80), 80)
    raw_input ("Press 'ENTER' to begin the first round: ")
    print ""         
    
    return playerOrder
开发者ID:churchie317,项目名称:wheel_of_fortune,代码行数:53,代码来源:Wheel_of_Fortune_v5.py



注:本文中的string.center函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python string.count函数代码示例发布时间:2022-05-27
下一篇:
Python string.capwords函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap