일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
29 | 30 |
Tags
- 데이터과학
- if문
- python
- 파이썬
- 코딩야학
- list
- 함수
- 이토록 쉬운 통계&R
- code
- 데이터사이언스
- BigData
- 임경덕
- 리스트
- big_data
- sql
- hadoop
- DataAnalysis
- 숫자야구소스
- for문
- 숫자야구
- stat
- 데이터분석
- 생활코딩
- DATABASE
- 하둡
- 숫자야구코드
- 빅데이터
- R
- 야학
- 루비페이퍼
Archives
- Today
- Total
yekang
리스트 슬라이싱, set 본문
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | info='kim12365100 89 87' print(info[:3]) print(info[3:8]) # :뒤 숫자는 포함이 안되기 때문에 +1해준다. print(info[8:11]) print(info[11:14]) print(info[14:]) -------------------------------------------------------------------------- infov2='kim,12365,100,89,87' r=infov2.split(",") #() 안에 구분자 넣으면 구분자로 나누어서 return해준다. sum=0 for item in r: print(item) for item in r[2:]: sum=sum+int(item) print('합계는=>', sum) -------------------------------------------------------------------------- data=[1,2,3,4] print(data[:2]) print(data[::-1]) list2list=[[1,2,4,6,8],[2,4,16,27,81,3]] print('1,3의 요소는=>',(list2list[1][3])) #grades = { "Joe":['1234',80,20,90],"Tim":['2314',87,95,95]} a = {'name': 'pey', 'phone': '0119993323', 'birth': '1118'} #print(joe_grade) print(a.keys()) print(a.values()) --------------------------------------------------------------------------- tweet={"user":"joelgrus","text":"Data science is Awesome","retweet_count":100,"hashtags":["#data","#science","#datascience",'#awesome','#yolo']} tweet_keys=tweet.keys() tweet_values=tweet.values() tweet_items=tweet.items() print(tweet_keys) print() print(tweet_values) print() print(tweet_items) print() print() print() ---------------------------------------------------------------------------- grades={"Joe":['1234',80,20,90],"Tim":['2314',87,95,95],"Kate":['3154',67,85,100]} try: joe_grades=grades["Joe"] except KeyError: print("no grade for Joe") print(joe_grades) print(grades.keys()) print(grades.values()) names=grades.keys() for name in names: print('key=%s,value-%s'%(name,grades[name])) ----------------------------------------------------------------------------- # set s=set([1,2,2,3,4]) print(len(s)) print(list(s)) | cs |
'빅데이터 > 파이썬' 카테고리의 다른 글
mymodule.py (0) | 2017.07.06 |
---|---|
[파일입출력]총점이 가장 큰 학생의 학번은? (0) | 2017.07.06 |
달력 함수 및 호출 (0) | 2017.07.05 |
리스트 슬라이싱 (0) | 2017.07.04 |
숫자야구게임 만들기 - 나의 코드 (0) | 2017.07.03 |
Comments