FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python/base/3/makeTextFile.py at data-struct · Onlykee/python · GitHub
Onlykee
/
python
Public
forked from
flypythoncom/python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
python
/
base
/
3
/
makeTextFile.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
32 lines (25 loc) · 594 Bytes
Breadcrumbs
python
/
base
/
3
/
makeTextFile.py
Copy path
File metadata and controls
32 lines (25 loc) · 594 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
'makeTextFile.py -- create text file'
import
os
ls
=
os
.
linesep
#get filename
while
True
:
fname
=
raw_input
()
if
os
.
path
.
exists
(
fname
):
print
"ERROR: '%s' already exists "
%
fname
else
:
break
#get file content lines
all
=
[]
print
"
\n
Enter lines:('.' by itself to quit)
\n
"
#loop until user terminates input
while
True
:
entry
=
raw_input
(
'>'
)
if
entry
==
'.'
:
break
else
:
all
.
append
(
entry
)
#write lines to file with proper line-ending
fobj
=
open
(
fname
,
'w'
)
fobj
.
writelines
([
'%s%s'
%
(
x
,
ls
)
for
x
in
all
])
fobj
.
close
()
print
'DONE!'
Back
|
FazBrowse Home
|
New Git URL