交作业
Topic source由于逗号的原因,f到s4的输出,之前全部都有空格 123 456.789 hello,world hello,"adam" hello,\"bart\" hello, "lisa"! 这个有什么方法可以对齐吗?
n = 123
f = 456.789
s1 = 'Hello, world'
s2 = 'Hello, \'Adam\''
s3 = r'Hello, "Bart"'
s4 = r'''Hello,
Lisa!'''
print('n =',n,'\nf =',f,'\ns1 =',s1,'\ns2 =',s2,'\ns3 =',s3,'\ns4 =',s4)
作业在此,各位避让
#变量
n = 123
f = 456.789
s1 = 'Hello, world'
s2 = 'Hello, \'Adam\''
s3 = r'Hello, "Bart"'
s4 = r'''Hello,
Lisa!'''
#打印出的变量的值方法1(但是会自动向右缩进一格)
print(n,'\n',f,'\n',s1,'\n',s2,'\n',s3,'\n',s4)
#打印出的变量的值方法2
print(n)
print(f)
print(s1)
print(s2)
print(s3)
print(s4)
#打印出的变量的值方法3
print(str(n)+'\n'+str(f)+'\n'+s1+'\n'+s2+'\n'+s3+'\n'+s4)
- 1
toLT
print(" \tbanna\tapple\tpear\t\nprice\t1元/斤\t2元/斤\t3元/斤\t\ntotal\t10斤\t15斤\t20斤\n")
n=123 f=456.789 s1="hello,world" s2="hello,\"adam\"" s3=r"hello,\"bart\"" s4=r'''hello, \"lisa\"! how are you?''' s5='''hi, \"hanmeimei\", how are you?''' print(n,"\n",f,"\n",s1,"\n",s2,"\n",s3,"\n",s4,"\n",s5)