[Python] 3 Ways of Formatted String
There are 3 ways to write a formatted string in Python3. Let's check it one by one. Formatted String with Placeholder This method seems like a C language. It uses string-formatting operator %. print("String: %c, %s" % ('h', 'python')) # String: hello, python print("Integer: %d, %i" % (3, 7)) # Integer: 3, 7 print("Floating: %f, %F, %3.2f" % (2.818, 1.414, 3.14159)) # Floating: 2.818000, 1.414000..
2021. 1. 22.
[Python] List (Array) Data Structure
List is a data structure like Array. Elements in the List can be duplicated. Creating List ### [] method emptyList = [] weekdayList = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'] nameList = ['Kim', 'Lee', 'Park', 'Kim'] ### list() function emptyList = list() testList = list('cat') # from String print(testList) # ['c', 'a', 't'] testTuple = ('red', 'green', 'blue') testList = list(testTuple) # from Tuple ..
2020. 12. 7.