[英]Python - Quotation Marks as Variables
Is it possible to use quotation marks as a variable? 是否可以将引号用作变量?
a = input("Insert Here")
If a is " " ":
Do something
Also, would I have to do = or Is ? 另外,我必须要做=或Is吗?
If you have double quotes inside a string literal then use single quotes, or escape it. 如果字符串文字中有双引号,则使用单引号或将其转义。
Don't use is
unless you want to see if two references refer to the same object. 除非要查看两个引用是否引用同一对象,否则不要使用
is
。 To test equality use ==
, a single =
is an assignment: 要测试是否相等,请使用
==
,一个=
是一个赋值:
a = input("Insert Here: ")
if a == '"':
Do something
you have two options: 您有两种选择:
'"'
'"'
"\\""
"\\""
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.