这是我的密码:
import random
name="srp"
age=14
gender="male"
vote="N/A"
def about_user():
aboutusr1="Your name is",name,".\nYou are",age,"years old.\nYour gender is",gender,".\nFun fact -",vote," :)"
aboutusr2="You are my master whose name is",name,".\nYour age is",age,"and your gender is",gender,".\nAlso, I know that",vote
L1=[aboutusr1, aboutusr2]
c=random.choice(L1)
print(c)
abs=input("Ask me :")
if "about me" in abs:
about_user()
输出:
Ask me :about me ('Your name is', 'srp', '.\nYou are', 14, 'years old.\nYour gender is', 'male', '.\nFun fact -', 'N/A', ' :)')
但我不想要开始和结束括号,单引号。此外,新行的\n
等内容也不会打印。
请帮帮我
更改
aboutusr1
和aboutusr2
如下(使用str.format())输出
或者正如@sim在注释中解释的那样,在代码中使用
print(*c)
(*
willunpack the tuple)如果使用python 3,则可以使用fstring:
相关问题 更多 >
编程相关推荐