Python-100-Days icon indicating copy to clipboard operation
Python-100-Days copied to clipboard

练习中 print 的更好写法

Open Nekobaex opened this issue 2 years ago • 1 comments

可以用一些更简单的的字符串格式化方法

  • 如变量插入字符串:
       friend1 = "neko"
       friend2 = "Deta"
       print(f"My friends are {friend1} and {friend2}")
    
  • 还有另一种简单的方法
       friend = "neko"
       print("My friend is", friend) 
       # 上面两个字符串之间会插入一个空格
    

Nekobaex avatar Jul 27 '22 09:07 Nekobaex

friend1 = "neko" friend2 = "Deta" print(f'My friends are {friend1} and {friend2}')

bestofyour avatar Jul 28 '22 09:07 bestofyour