python中 r'' ,b'', f''含义

字符串前加 f format() 函数
name = "大帝"
age = 12
print(f"my name is {name},age is {age}")

结果:
my name is 大帝,age is 12

r""  的作用是:去除转义字符
print(r"F:\Python_Easy\number\testone.py ")
结果 F:\Python_Easy\number\testone.py
不用r的情况 
print("F:\Python_Easy\number\testone.py ")
结果:
F:\Python_Easy
umber    estone.py 
字符串前加 b
b" "的作用是:后面字符串是bytes 类型
print(b'\xe4\xb8\xad\xe6\x96\x87'.decode())
b'\xe4\xb8\xad\xe6\x96\x87'

 

posted on 2023-02-10 10:55  kevin_yang123  阅读(900)  评论(0编辑  收藏  举报