2009-12-09 183 views
0

S = '這是樣本'字符串轉換

我需要這樣的

s='"This is sample"' 

輸出轉換= "This is sample"

如何提前做動態
感謝

回答

5
orig = 'This is sample' 
converted = '"%s"' % orig 
+0

非常感謝你 – Kumar 2009-12-09 12:52:49

+0

短簡單正確 – DrFalk3n 2009-12-09 13:57:18

1
>>> s= 'This is a sample' 
>>> s = '"' + s + '"' # or s = '"%s"' % s 
>>> s 
'"This is a sample"' 
>>> print(s) 
"This is a sample" 
>>>