join takes the string as a delimiter and concatenates the content of the list with this delimiter between each element. If you do need a list, you can wrap it in list(map(.)), but at that point a list comprehension is more clear. > '.'.join (map (str, deints)) '10.10.10.50'. Thinking in terms of types, the original variable you have is of type Listint (1, 2, 3). Note that in Python 3, map returns a map object instead of a list. The string join() method returns a string by joining all the elements of an iterable (list, string, tuple), separated by the given separator. It provides string-to-list conversion by using delimiters to separate strings. Python Dictionaries Access Items Change Items Add Items Remove Items Loop Dictionaries Copy Dictionaries Nested Dictionaries Dictionary Methods Dictionary Exercise Python If.Else Python While Loops Python For Loops Python Functions Python Lambda Python Arrays Python Classes/Objects Python Inheritance Python Iterators Python Polymorphism Python Scope Python Modules Python Dates Python Math Python JSON Python RegEx Python PIP Python Try. You can use the join method on strings and have to convert the data in the list to strings first. In Python, a split is a built-in function.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |