Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- #위도#경도#비정형데이터#크롤링
- 카카오APi
- #K-means #Clustering
- 웹매크로 #세잔느
- #크롤링 #웹문서
- 웹크롤링
- 위도경도
- 코딩
- 파이썬
- 셀레니움
- #비정형#카카오api#api#크롤링
- 구글 지오코드
- 숫자빼고 중복되는 코드동작법
- #비정형 데이터 #네이버 #지도 #크롤링
- 파이썬 셀레니움
Archives
- Today
- Total
지방이의 Data Science Lab
[python] 문자열 자료형 (1) f "~~{ }", .format('x'), %d, %s 본문
편리하다고 생각되는 순서대로 정리해두었다. 3.6버전 이상부터 사용가능한 f "~~{변수명}"이 제일 편하다고 느껴진다.
다만 자릿수를 고정할 때 다음과 같이 쓴다.
name = "Eric"
age = 74
temp = f"Hello, {name}. You are {age :03d}."
>> 'Hello, Eric. You are 074.'
#0. f "~~{ }"
1
2
3
4
5
6
7
8
9
|
name = '지방이'
b = f"adf {name} asdf."
print(b)
adf 지방이 asdf.
age = 29
b = f'asdf {age} asdf {name}'
print(b)
asdf 29 asdf 지방이
|
#1. .format()
1
2
3
|
b = "adf {} asdf.".format('지방이')
print(b)
adf 지방이 asdf.
|
1
2
3
4
|
a = 'aasdf {age} asdf asdf {name} adf.'.format(name = '지방이', age = 29)
print(a)
aasdf 29 asdf asdf 지방이 adf.
|
#2. %d, %s
문자열 포매팅
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#숫자형
numb = 3
b = "adf %d asdf." %numb
print(b)
adf 3 asdf.
#문자열
string = 'three'
b = "adf %s asdf." %string
print(b)
adf three asdf.
#두개 한번에
numb = 3
days = 'three'
b = "adf %d adsf %s asdf." %(numb, days)
print(b)
adf 3 adsf three asdf.
|
'Data Analysis > Codility' 카테고리의 다른 글
[python] 리스트 자료형(1) 덧셈, 곱셈 (0) | 2021.01.08 |
---|---|
[python] 문자열 자료형(4).join( ), upper( ), strip( ) (0) | 2021.01.08 |
[python] 문자열 자료형(3) .count('x'), .find('x'), .replace('a', 'b') (0) | 2021.01.08 |
[python] 리스트 특성 (0) | 2020.09.07 |
[python] 리스트를 카운트해서 dictionary를 만들어보기 (0) | 2020.08.01 |
Comments