如何在str中使用%包含列表?python问题
我最近开始学习另一种编程语言Python。但我在章节字符串格式方面遇到了一个问题 我的问题是,当我们通过符号%c或%d在字符串中包含整数、浮点数、变量等时,是否有一种方法可以直接包含列表而不拆分变量数 foo=[1,3,这是str.]list 打印按摩是“%SOMETHING”,foo 您可以在python 3.6+上使用 只用 v_列表=[3.6,'as',4] printf'Showing{v_list}' 您可以在python 3.6+上使用 只用 v_列表=[3.6,'as',4] printf'Showing{v_list}'如何在str中使用%包含列表?python问题,python,python-3.x,string,list,printing,Python,Python 3.x,String,List,Printing,我最近开始学习另一种编程语言Python。但我在章节字符串格式方面遇到了一个问题 我的问题是,当我们通过符号%c或%d在字符串中包含整数、浮点数、变量等时,是否有一种方法可以直接包含列表而不拆分变量数 foo=[1,3,这是str.]list 打印按摩是“%SOMETHING”,foo 您可以在python 3.6+上使用 只用 v_列表=[3.6,'as',4] printf'Showing{v_list}' 您可以在python 3.6+上使用 只用 v_列表=[3.6,'as',4] pr
在Python中,可以使用如下格式字符串方法将列表插入字符串: 1打印消息为{}.formatlist 或
2打印消息为{ls}.formatls=list在Python中,可以使用如下格式字符串方法将列表插入字符串: 1打印消息为{}.formatlist 或
2打印消息为{ls}。formatls=list您可以使用str将列表转换为字符串:
foo = [1, 2,' this is str']
print("This is your list: '", str(foo), "' and its great!")
结果将是:
This is your list: '[1, 2,' this is str']' and its great!
可以使用str将列表转换为字符串:
foo = [1, 2,' this is str']
print("This is your list: '", str(foo), "' and its great!")
结果将是:
This is your list: '[1, 2,' this is str']' and its great!
%s对任何东西都有效。%s对任何东西都有效。