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 | 29 | 30 | 31 |
Tags
- ๋๊ธฐ
- https://m.blog.naver.com/tt2t2am1118/221010125300
- setTimeout()
- callback
- execCommand
- addEventListener
- prj
- mysql
- eport
- sql
- async
- await
- db
- ajax
- slow and steady
- Import
- json
- ์ฐธ๊ณ ๋ธ๋ก๊ทธ
- database
- JS #ํ๋ก์ ํธ
- https://youtube.com/playlist?list=PLuHgQVnccGMA5836CvWfieEQy0T0ov6Jh&si=FTaYv8m21EhO-A2K
- webpack
- ํผํ
- Project
- ๋น๋๊ธฐ
- Porject
- promise
- object
- js
- ๊ฒ์
Archives
- Today
- Total
C-log
Welcome to Python : ํ์ผ ์ฝ๊ณ ์ฐ๊ธฐ ๋ณธ๋ฌธ
728x90
- ํจ์ : https://hi-code.tistory.com/119
- ์ฌ์ฉ์ ์ ์ถ๋ ฅ : https://hi-code.tistory.com/120
- ํ์ผ ์ฝ๊ณ ์ฐ๊ธฐ : https://hi-code.tistory.com/121
- ํ๋ก๊ทธ๋จ์ ์ ์ถ๋ ฅ : https://hi-code.tistory.com/122
Title | Code | Console |
ํ์ผ ์ฝ๊ณ ์ฐ๊ธฐ | ||
ํ์ผ ์์ฑํ๊ธฐ |
f = open("์ํ์ผ.txt", 'w') f.close
|
|
ํ์ผ ์ด๊ธฐ ๋ชจ๋ | r - ์ฝ๊ธฐ ๋ชจ๋ : ํ์ผ์ ์ฝ๊ธฐ๋ง ํ ๋ ์ฌ์ฉํ๋ค. w - ์ฐ๊ธฐ ๋ชจ๋ : ํ์ผ์ ๋ด์ฉ์ ์ธ ๋ ์ฌ์ฉํ๋ค. a - ์ถ๊ฐ ๋ชจ๋ : ํ์ผ์ ๋ง์ง๋ง์ ์๋ก์ด ๋ด์ฉ์ ์ถ๊ฐํ ๋ ์ฌ์ฉํ๋ค. |
|
ํ์ผ(w)์ ์ด์ด ๋ด์ฉ ์ฐ๊ธฐ |
f = open("์ํ์ผ.txt", 'w') for i in range(1, 11):
data = "%d๋ฒ์งธ ์ค์
๋๋ค.\n" % i
f.write(data)
f.close
|
|
readline ํจ์ |
f = open("์ํ์ผ.txt", 'r') line = f.readline()
print(line)
f.close()
|
1๋ฒ์งธ ์ค์ ๋๋ค. |
f = open("์ํ์ผ.txt", 'r') while True:
line = f.readline()
if not line:
break
print(line)
f.close()
|
1๋ฒ์งธ ์ค์
๋๋ค. 2๋ฒ์งธ ์ค์ ๋๋ค. 3๋ฒ์งธ ์ค์ ๋๋ค. . . . 10๋ฒ์งธ ์ค์ ๋๋ค. |
|
readline's'ํจ์ |
f = open("์ํ์ผ.txt", 'r') lines = f.readlines()
for line in lines:
print(line)
f.close
|
1๋ฒ์งธ ์ค์
๋๋ค. 2๋ฒ์งธ ์ค์ ๋๋ค. . . . 10๋ฒ์งธ ์ค์ ๋๋ค. |
.strip() |
f = open("์ํ์ผ.txt", 'r') lines = f.readlines()
for line in lines:
line = line.strip()
print(line)
f.close
|
1๋ฒ์งธ ์ค์
๋๋ค. . . . 8๋ฒ์งธ ์ค์ ๋๋ค. 9๋ฒ์งธ ์ค์ ๋๋ค. 10๋ฒ์งธ ์ค์ ๋๋ค. |
readํจ์ |
f = open("์ํ์ผ.txt", 'r') data = f.read()
print(data)
f.close
|
|
ํ์ผ ๊ฐ์ฒด for๋ฌธ |
f = open("์ํ์ผ.txt", 'r') for line in f:
print(line)
f.close
|
|
์๋ก์ด ๋ด์ฉ ์ถ๊ฐํ๊ธฐ |
f = open("์ํ์ผ.txt", 'a') for i in range(11, 20):
data = "%d๋ฒ์งธ ์ค์
๋๋ค.\n" % i
f.write(data)
f.close
|
'11๋ฒ์งธ ์ค์ ๋๋ค.'์์ '20๋ฒ์งธ ์ค์ ๋๋ค.'๊น์ง ์ถ๊ฐ๊ฐ ๋๋ค. |
with๋ฌธ ์ฌ์ฉํ๊ธฐ |
with open("foo.txt", "w") as f: f.write("Life is too short, you need python")
|
728x90
'๐Python' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Welcome to Python : ํด๋์ค (0) | 2023.07.21 |
---|---|
Welcome to Python : ํ๋ก๊ทธ๋จ์ ์ ์ถ๋ ฅ (0) | 2023.07.13 |
Welcome to Python : ์ฌ์ฉ์ ์ ์ถ๋ ฅ (0) | 2023.07.13 |
Welcome to Python : ํจ์ (0) | 2023.07.13 |
Welcome to Python : for๋ฌธ (0) | 2023.07.09 |
Comments