Python字符串报错:'I'm a student.' 如何解决?
是的,因为字符串中包含了单引号。
可以使用双引号替换单引号,或者在单引号前加上转义字符\来修正字符串,如下所示:
string1="I'm a student."
print(string1)
或者:
string1='I\'m a student.'
print(string1)
原文地址: http://www.cveoy.top/t/topic/n0kk 著作权归作者所有。请勿转载和采集!
安全问答是一个知识全球问答,包含丰富的问答知识
是的,因为字符串中包含了单引号。
可以使用双引号替换单引号,或者在单引号前加上转义字符\来修正字符串,如下所示:
string1="I'm a student."
print(string1)
或者:
string1='I\'m a student.'
print(string1)
原文地址: http://www.cveoy.top/t/topic/n0kk 著作权归作者所有。请勿转载和采集!