%s在python格式字符串中意味着什么?什么%s在Python里?下面的代码是做什么的?比如说.。 if len(sys.argv) < 2:
sys.exit('Usage: %s database-name' % sys.argv[0])
if not os.path.exists(sys.argv[1]):
sys.exit('ERROR: Database %s was not found!' % sys.argv[1])
3 回答

POPMUISE
TA贡献1765条经验 获得超5个赞
"Hello %s, my name is %s" % ('john', 'mike') # Hello john, my name is mike".
"My name is %s and i'm %d" % ('john', 12) #My name is john and i'm 12

手掌心
TA贡献1942条经验 获得超3个赞
format
>>> "Hello {}, my name is {}".format('john', 'mike')'Hello john, my name is mike'.>>> "{1}, {0}".format('world', 'Hello')'Hello, world'>>> "{greeting}, {}".format('world', greeting='Hello')'Hello, world'>>> '%s' % name"{'s1': 'hello', 's2': 'sibal'}">>> '%s' %name['s1']'hello'
添加回答
举报
0/150
提交
取消