5 回答
TA贡献1812条经验 获得超5个赞
你可以这样做:
>>> quote = "\"A person who never made a mistake never tried anything new.\""
>>> message = f"Albert Einstein once said, {quote}"
>>> print(message)
Albert Einstein once said, "A person who never made a mistake never tried anything new."
或者你也可以这样做:
>>> quote = "A person who never made a mistake never tried anything new."
>>> message = f"Albert Einstein once said, \"{quote}\""
>>> print(message)
Albert Einstein once said, "A person who never made a mistake never tried anything new."
或者,您可以用单引号将双引号括起来,以便打印双引号。
做这样的事情:
>>> quote = '"A person who never made a mistake never tried anything new."'
>>> message = f"Albert Einstein once said, {quote}"
>>> print(message)
Albert Einstein once said, "A person who never made a mistake never tried anything new."
请注意,如果句子中有单引号,则它将不起作用。例如,如果您的句子是 "A person who's never made a mistake never tried anything new",那么单引号将不起作用。
TA贡献1883条经验 获得超3个赞
尝试这个:
a = "Albert Einstein once said, \"A person who never made a mistake never tried anything new.\"" print(a)
或者:
a = 'Albert Einstein once said,"A person who never made a mistake never tried anything new."' print(a)
TA贡献1844条经验 获得超8个赞
尝试用
quote = '"A person who never made a mistake never tried anything new."'
message = "Albert Einstein once said, {}".format(quote)
print(message)
TA贡献1793条经验 获得超6个赞
尝试这个
quote = '"A person who never made a mistake never tried anything new."'
message = f"Albert Einstein once said, {quote}"
print(message)
TA贡献1906条经验 获得超10个赞
您需要在引号前添加反斜杠。
print("test test hello /" very good /" said him")
输出:
测试测试你好他说“很好”
添加回答
举报