
# fstring
name = 'Bill'
age = 20
def getAge():
return 21
s = f'我是{name}, 我今年{age}岁, 明年{getAge()}岁'
print(s)我是Bill, 我今年20岁, 明年21岁class Person:
def __init__(self):
self.name = 'Mike'
self.age1 = 40
def getAge(self):
return 41
person = Person()
s1 = f'我是{name}, 我今年{person.age1}岁, 明年{person.getAge()}岁'
print(s1)我是Bill, 我今年40岁, 明年41岁原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。