首页 > 编程语言 >python-f字符串(f-string)99乘法表三种方式

python-f字符串(f-string)99乘法表三种方式

时间:2022-08-21 17:23:45浏览次数:57  
标签:10 end string python range print 乘法表

#%s打印99乘法表
for i in range(1,10):
for j in range(1,i+1):
print("%s*%s=%s" %(j,i,j*i),end=" ")
print("\n")

#format打印九九乘法表
for i in range(1,10):
for j in range(1,i+1):
print("{0}*{1}={2}".format(j,i,j*i),end=" ")
print("\n")

#f-string方式
for i in range(1,10):
for j in range(1,i+1):
print(f"{j}*{i}={j*i}", end=" ")
print("\n")

标签:10,end,string,python,range,print,乘法表
From: https://www.cnblogs.com/yu-yuki/p/16610358.html

相关文章

  • Python教程 - 画折线图
    matplotlibmatplotlib是Python的绘图库,它能让使用者很轻松地将数据图形化,并且提供多样化的输出格式。matplotlib可以用来绘制各种静态,动态,交互式的图表。matplotlib......
  • Python教程 - 保存分数结果至文件
    保存文件的方法fns='test_out.txt'withopen(fns,'w+')asfs:print('helloworldbypython',file=fs)将上节课的分析的分数结果保存至文件importtkinter......
  • Time Needed to Rearrange a Binary String
    TimeNeededtoRearrangeaBinaryStringYouaregivenabinarystring$s$.Inonesecond,alloccurrencesof 01 aresimultaneouslyreplacedwith 10 .This......
  • Jedis快速入门和操作string
    Jedis快速入门Jedis:一款java操作redis数据库的工具使用步骤:1、下载jedis的jar包2、使用/***jedis的测试类*/publicclassJedisTest{/**......
  • Jedis快速入门和Jedis操作string
    Jedis快速入门Jedis:是一款java操作redis数据库的工具使用步骤:1.下载Jedis的jar包2.使用这两个jar包导入项目中 编写一个测试类JedisTest:/***Jedis的......
  • python 使用正则表达式截取字符串
    假设字符串“a={};”要截取包含花括号在内的内容importrepattern=r="=(.+?);"match_bet_list=eval(re.findall(pattern,match_bet_list,re.M)[0])re.M表示在字符......
  • python-%格式化输出
    输出输出使用的是print()函数,作用,将程序中的数据或结果打印到控制台(屏幕)print('helloworld')name='小明'print(name)age=18print(name,age)#可以使用逗号输出......
  • Python 处理html、url字符串编码和解码(base64,escape,urlencode)
    Base64是网络上最常见的用于传输8Bit字节码的编码方式之一,Base64就是一种基于64个可打印字符来表示二进制数据的方法。对html进行编码Python2.x中可以使用cgi中escape,Pyth......
  • 基于python的数学建模---logicstic回归
    樱花数据集的Logistic回归   绘制散点图importmatplotlib.pyplotaspltimportnumpyasnpfromsklearn.datasetsimportload_irisiris=load_iris()#获......
  • redis数据结构介绍以及命令操作string和hash类型
    redis的数据结构redis存储的是:key,value格式的数据,其中key都是字符串,value有5中不同的数据结构value的数据结构:(1)字符串类型string......