質問編集履歴

20

書式

2017/04/29 07:41

投稿

riekosuzuki
riekosuzuki

スコア11

test CHANGED
@@ -1 +1 @@
1
- Python3  CGIのwavファイルの読み込みに関してです。
1
+ PythonCGIのwavファイルの読み込みに関してです。
test CHANGED
File without changes

19

書式

2017/04/29 07:41

投稿

riekosuzuki
riekosuzuki

スコア11

test CHANGED
File without changes
test CHANGED
@@ -62,9 +62,9 @@
62
62
 
63
63
  ###該当のソースコード
64
64
 
65
- ```
66
-
67
- python
65
+ ```python
66
+
67
+
68
68
 
69
69
  import wave
70
70
 
@@ -160,8 +160,6 @@
160
160
 
161
161
  import sys
162
162
 
163
- import datetime
164
-
165
163
  import cgitb
166
164
 
167
165
 

18

書式

2017/04/29 07:38

投稿

riekosuzuki
riekosuzuki

スコア11

test CHANGED
File without changes
test CHANGED
@@ -180,11 +180,7 @@
180
180
 
181
181
  <body>
182
182
 
183
- <a href="http://tokyo-ft.com/"><img src="http://www.homepage-tukurikata.com/image/hoge.jpg" alt="TFT" width="233" height="165" border="0" /></a>
184
-
185
-
186
-
187
- <H1>%s</H1>
183
+ %s
188
184
 
189
185
  </body>
190
186
 

17

書式

2017/04/29 07:34

投稿

riekosuzuki
riekosuzuki

スコア11

test CHANGED
File without changes
test CHANGED
@@ -150,17 +150,9 @@
150
150
 
151
151
  ```
152
152
 
153
- ```
154
-
155
-
156
-
157
-
158
-
159
-
160
-
161
153
  ###試したこと
162
154
 
163
- 以下のように、textファイルを選択する場合はうまくいきます。
155
+ ###以下のように、textファイルを選択する場合はうまくいきます。
164
156
 
165
157
  ```
166
158
 

16

書式

2017/04/29 07:30

投稿

riekosuzuki
riekosuzuki

スコア11

test CHANGED
File without changes
test CHANGED
@@ -60,6 +60,8 @@
60
60
 
61
61
  ```
62
62
 
63
+ ###該当のソースコード
64
+
63
65
  ```
64
66
 
65
67
  python
@@ -160,7 +162,7 @@
160
162
 
161
163
  以下のように、textファイルを選択する場合はうまくいきます。
162
164
 
163
-
165
+ ```
164
166
 
165
167
  import cgi
166
168
 
@@ -228,7 +230,7 @@
228
230
 
229
231
 
230
232
 
231
-
233
+ ```
232
234
 
233
235
  ###補足情報(言語/FW/ツール等のバージョンなど)
234
236
 

15

書式

2017/04/29 07:28

投稿

riekosuzuki
riekosuzuki

スコア11

test CHANGED
File without changes
test CHANGED
@@ -16,9 +16,7 @@
16
16
 
17
17
 
18
18
 
19
- ``
19
+ ```
20
-
21
- <<エラー文>>
22
20
 
23
21
 
24
22
 
@@ -62,6 +60,8 @@
62
60
 
63
61
  ```
64
62
 
63
+ ```
64
+
65
65
  python
66
66
 
67
67
  import wave

14

書式

2017/04/29 07:25

投稿

riekosuzuki
riekosuzuki

スコア11

test CHANGED
File without changes
test CHANGED
@@ -64,23 +64,109 @@
64
64
 
65
65
  python
66
66
 
67
-
67
+ import wave
68
+
69
+ from pylab import *
70
+
71
+ import sys
72
+
73
+ from pydub import AudioSegment
74
+
75
+ import cgi
76
+
77
+ import cgitb
78
+
79
+
80
+
81
+ cgitb.enable()
82
+
83
+
84
+
85
+ html_body = u"""
86
+
87
+ <html>
88
+
89
+ <head>
90
+
91
+ <meta http-equiv="content-type"content="text/html\n"></head>
92
+
93
+ <body>
94
+
95
+ %s
96
+
97
+ </body>
98
+
99
+ </html>"""
100
+
101
+
102
+
103
+ form = cgi.FieldStorage()
104
+
105
+ wf = form['file']
106
+
107
+ length = float(wf.getnframes()) / wf.getframerate() # 波形長さ(秒)
108
+
109
+ content = length
110
+
111
+
112
+
113
+
114
+
115
+ print ("Content-type: text/html;charset=utf-8\n")
116
+
117
+ print ((html_body % content))
118
+
119
+
120
+
121
+
122
+
123
+ <<HTMLファイル>>
124
+
125
+
126
+
127
+ <html>
128
+
129
+ <head>
130
+
131
+ <meta http-equiv="content-type" content="text/html;charset=utf-8"> </head>
132
+
133
+ <body>
134
+
135
+ <form action="/cgi-bin/test1.py" method="post" enctype="multipart/form-data"> 入力してください。<br /> 必須 :
136
+
137
+ <input type="file" name="file" />
138
+
139
+ <button>Send the file</button>
140
+
141
+
142
+
143
+ </form>
144
+
145
+ </body>
146
+
147
+ </html>
68
148
 
69
149
  ```
70
150
 
151
+ ```
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+ ###試したこと
160
+
71
- ###以下のようにコードきました
161
+ 以下のように、textファイル選択する場合はうまくいきま
72
-
73
-
74
-
162
+
163
+
164
+
75
- import wave
165
+ import cgi
76
-
77
- from pylab import *
78
166
 
79
167
  import sys
80
168
 
81
- from pydub import AudioSegment
82
-
83
- import cgi
169
+ import datetime
84
170
 
85
171
  import cgitb
86
172
 
@@ -100,7 +186,11 @@
100
186
 
101
187
  <body>
102
188
 
189
+ <a href="http://tokyo-ft.com/"><img src="http://www.homepage-tukurikata.com/image/hoge.jpg" alt="TFT" width="233" height="165" border="0" /></a>
190
+
191
+
192
+
103
- %s
193
+ <H1>%s</H1>
104
194
 
105
195
  </body>
106
196
 
@@ -108,17 +198,29 @@
108
198
 
109
199
 
110
200
 
111
- form = cgi.FieldStorage()
201
+ form=cgi.FieldStorage()
112
-
202
+
113
- wf = form['file']
203
+ fileitem = form["file"]
204
+
114
-
205
+ kek =[]
206
+
207
+ if fileitem.file:
208
+
209
+
210
+
211
+ linecount = 0
212
+
213
+ while True:
214
+
115
- length = float(wf.getnframes()) / wf.getframerate() # 波形長さ(秒)
215
+ line = fileitem.file.readline()
216
+
116
-
217
+ kek.append(line)
218
+
219
+ if not line: break
220
+
221
+ linecount = linecount + 1
222
+
117
- content = length
223
+ content = kek
118
-
119
-
120
-
121
-
122
224
 
123
225
  print ("Content-type: text/html;charset=utf-8\n")
124
226
 
@@ -128,108 +230,6 @@
128
230
 
129
231
 
130
232
 
131
- <<HTMLファイル>>
132
-
133
-
134
-
135
- <html>
136
-
137
- <head>
138
-
139
- <meta http-equiv="content-type" content="text/html;charset=utf-8"> </head>
140
-
141
- <body>
142
-
143
- <form action="/cgi-bin/test1.py" method="post" enctype="multipart/form-data"> 入力してください。<br /> 必須 :
144
-
145
- <input type="file" name="file" />
146
-
147
- <button>Send the file</button>
148
-
149
-
150
-
151
- </form>
152
-
153
- </body>
154
-
155
- </html>```
156
-
157
- ```
158
-
159
- ###試したこと
160
-
161
- 以下のように、textファイルを選択する場合はうまくいきます。
162
-
163
-
164
-
165
- import cgi
166
-
167
- import sys
168
-
169
- import datetime
170
-
171
- import cgitb
172
-
173
-
174
-
175
- cgitb.enable()
176
-
177
-
178
-
179
- html_body = u"""
180
-
181
- <html>
182
-
183
- <head>
184
-
185
- <meta http-equiv="content-type"content="text/html\n"></head>
186
-
187
- <body>
188
-
189
- <a href="http://tokyo-ft.com/"><img src="http://www.homepage-tukurikata.com/image/hoge.jpg" alt="TFT" width="233" height="165" border="0" /></a>
190
-
191
-
192
-
193
- <H1>%s</H1>
194
-
195
- </body>
196
-
197
- </html>"""
198
-
199
-
200
-
201
- form=cgi.FieldStorage()
202
-
203
- fileitem = form["file"]
204
-
205
- kek =[]
206
-
207
- if fileitem.file:
208
-
209
-
210
-
211
- linecount = 0
212
-
213
- while True:
214
-
215
- line = fileitem.file.readline()
216
-
217
- kek.append(line)
218
-
219
- if not line: break
220
-
221
- linecount = linecount + 1
222
-
223
- content = kek
224
-
225
- print ("Content-type: text/html;charset=utf-8\n")
226
-
227
- print ((html_body % content))
228
-
229
-
230
-
231
-
232
-
233
233
  ###補足情報(言語/FW/ツール等のバージョンなど)
234
234
 
235
235
  より詳細な情報

13

書式

2017/04/29 07:21

投稿

riekosuzuki
riekosuzuki

スコア11

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,6 @@
1
1
  ##
2
2
 
3
- python初心者(python3.5)です。riekoと申します。CGIの勉強をしていましてwavファイルの読み込みの方法がどうしてもわかりません。どなたかpythonに詳しい方、ご教示をお願いいたします。
3
+ python初心者(python3.5)です。CGIの勉強をしていましてwavファイルの読み込みの方法がどうしてもわかりません。どなたかpythonに詳しい方、ご教示をお願いいたします。
4
4
 
5
5
  例えば、wavファイルを選択して、そのwavファイルの長さを返したい場合、以下のようにコードを書いたのですが、
6
6
 

12

書式

2017/04/29 07:04

投稿

riekosuzuki
riekosuzuki

スコア11

test CHANGED
@@ -1 +1 @@
1
- Pythonのwavファイルの読み込みに関してです。
1
+ Python3  CGIのwavファイルの読み込みに関してです。
test CHANGED
File without changes

11

書式

2017/04/29 06:59

投稿

riekosuzuki
riekosuzuki

スコア11

test CHANGED
File without changes
test CHANGED
@@ -62,7 +62,7 @@
62
62
 
63
63
  ```
64
64
 
65
- python<改行>プログラムの中身・・・<改行>
65
+ python
66
66
 
67
67
 
68
68
 

10

書式

2017/04/29 06:50

投稿

riekosuzuki
riekosuzuki

スコア11

test CHANGED
File without changes
test CHANGED
@@ -62,7 +62,9 @@
62
62
 
63
63
  ```
64
64
 
65
- python3
65
+ python<改行>プログラムの中身・・・<改行>
66
+
67
+
66
68
 
67
69
  ```
68
70
 

9

2017/04/29 06:49

投稿

riekosuzuki
riekosuzuki

スコア11

test CHANGED
File without changes
test CHANGED
File without changes

8

書式

2017/04/29 04:34

投稿

riekosuzuki
riekosuzuki

スコア11

test CHANGED
File without changes
test CHANGED
@@ -66,7 +66,7 @@
66
66
 
67
67
  ```
68
68
 
69
- ###以下のようにコード以下のようにを書きました。
69
+ ###以下のようにコードを書きました。
70
70
 
71
71
 
72
72
 

7

書式

2017/04/29 03:50

投稿

riekosuzuki
riekosuzuki

スコア11

test CHANGED
File without changes
test CHANGED
@@ -204,7 +204,7 @@
204
204
 
205
205
  if fileitem.file:
206
206
 
207
- # It's an uploaded file; count lines
207
+
208
208
 
209
209
  linecount = 0
210
210
 

6

書式

2017/04/29 03:49

投稿

riekosuzuki
riekosuzuki

スコア11

test CHANGED
File without changes
test CHANGED
@@ -66,13 +66,7 @@
66
66
 
67
67
  ```
68
68
 
69
- 試したコード
70
-
71
-
72
-
73
- #!/usr/bin/env python
69
+ ###以下のようにコード以下のようにを書きました。
74
-
75
- # coding: utf-8
76
70
 
77
71
 
78
72
 
@@ -164,9 +158,7 @@
164
158
 
165
159
  以下のように、textファイルを選択する場合はうまくいきます。
166
160
 
167
- #!/usr/bin/env python
161
+
168
-
169
- # coding: utf-8
170
162
 
171
163
  import cgi
172
164
 

5

書式

2017/04/29 03:47

投稿

riekosuzuki
riekosuzuki

スコア11

test CHANGED
File without changes
test CHANGED
@@ -62,10 +62,14 @@
62
62
 
63
63
  ```
64
64
 
65
- ``````Python3
65
+ python3
66
66
 
67
67
  ```
68
68
 
69
+ 試したコード
70
+
71
+
72
+
69
73
  #!/usr/bin/env python
70
74
 
71
75
  # coding: utf-8

4

書式

2017/04/29 03:43

投稿

riekosuzuki
riekosuzuki

スコア11

test CHANGED
File without changes
test CHANGED
@@ -62,9 +62,7 @@
62
62
 
63
63
  ```
64
64
 
65
- ``````ここに言語を入力
65
+ ``````Python3
66
-
67
- python3
68
66
 
69
67
  ```
70
68
 

3

書式

2017/04/29 03:41

投稿

riekosuzuki
riekosuzuki

スコア11

test CHANGED
File without changes
test CHANGED
@@ -62,6 +62,12 @@
62
62
 
63
63
  ```
64
64
 
65
+ ``````ここに言語を入力
66
+
67
+ python3
68
+
69
+ ```
70
+
65
71
  #!/usr/bin/env python
66
72
 
67
73
  # coding: utf-8
@@ -150,7 +156,7 @@
150
156
 
151
157
  </html>```
152
158
 
153
-
159
+ ```
154
160
 
155
161
  ###試したこと
156
162
 

2

誤字

2017/04/29 03:40

投稿

riekosuzuki
riekosuzuki

スコア11

test CHANGED
File without changes
test CHANGED
@@ -160,17 +160,11 @@
160
160
 
161
161
  # coding: utf-8
162
162
 
163
-
164
-
165
- import wave
163
+ import cgi
166
-
167
- from pylab import *
168
164
 
169
165
  import sys
170
166
 
171
- from pydub import AudioSegment
172
-
173
- import cgi
167
+ import datetime
174
168
 
175
169
  import cgitb
176
170
 
@@ -190,6 +184,10 @@
190
184
 
191
185
  <body>
192
186
 
187
+ <a href="http://tokyo-ft.com/"><img src="http://www.homepage-tukurikata.com/image/hoge.jpg" alt="TFT" width="233" height="165" border="0" /></a>
188
+
189
+
190
+
193
191
  <H1>%s</H1>
194
192
 
195
193
  </body>
@@ -198,17 +196,29 @@
198
196
 
199
197
 
200
198
 
201
- form = cgi.FieldStorage()
199
+ form=cgi.FieldStorage()
202
-
200
+
203
- wf = form['file']
201
+ fileitem = form["file"]
202
+
204
-
203
+ kek =[]
204
+
205
+ if fileitem.file:
206
+
207
+ # It's an uploaded file; count lines
208
+
209
+ linecount = 0
210
+
211
+ while True:
212
+
205
- length = float(wf.getnframes()) / wf.getframerate() # 波形長さ(秒)
213
+ line = fileitem.file.readline()
214
+
206
-
215
+ kek.append(line)
216
+
217
+ if not line: break
218
+
219
+ linecount = linecount + 1
220
+
207
- content = length
221
+ content = kek
208
-
209
-
210
-
211
-
212
222
 
213
223
  print ("Content-type: text/html;charset=utf-8\n")
214
224
 
@@ -216,10 +226,6 @@
216
226
 
217
227
 
218
228
 
219
-
220
-
221
- ```
222
-
223
229
 
224
230
 
225
231
  ###補足情報(言語/FW/ツール等のバージョンなど)

1

書式

2017/04/29 03:32

投稿

riekosuzuki
riekosuzuki

スコア11

test CHANGED
File without changes
test CHANGED
@@ -62,167 +62,165 @@
62
62
 
63
63
  ```
64
64
 
65
-
65
+ #!/usr/bin/env python
66
+
66
-
67
+ # coding: utf-8
68
+
69
+
70
+
71
+ import wave
72
+
73
+ from pylab import *
74
+
75
+ import sys
76
+
77
+ from pydub import AudioSegment
78
+
79
+ import cgi
80
+
81
+ import cgitb
82
+
83
+
84
+
85
+ cgitb.enable()
86
+
87
+
88
+
89
+ html_body = u"""
90
+
91
+ <html>
92
+
93
+ <head>
94
+
95
+ <meta http-equiv="content-type"content="text/html\n"></head>
96
+
97
+ <body>
98
+
99
+ %s
100
+
101
+ </body>
102
+
103
+ </html>"""
104
+
105
+
106
+
107
+ form = cgi.FieldStorage()
108
+
109
+ wf = form['file']
110
+
111
+ length = float(wf.getnframes()) / wf.getframerate() # 波形長さ(秒)
112
+
113
+ content = length
114
+
115
+
116
+
117
+
118
+
119
+ print ("Content-type: text/html;charset=utf-8\n")
120
+
121
+ print ((html_body % content))
122
+
123
+
124
+
125
+
126
+
127
+ <<HTMLファイル>>
128
+
129
+
130
+
131
+ <html>
132
+
133
+ <head>
134
+
135
+ <meta http-equiv="content-type" content="text/html;charset=utf-8"> </head>
136
+
137
+ <body>
138
+
139
+ <form action="/cgi-bin/test1.py" method="post" enctype="multipart/form-data"> 入力してください。<br /> 必須 :
140
+
141
+ <input type="file" name="file" />
142
+
143
+ <button>Send the file</button>
144
+
145
+
146
+
147
+ </form>
148
+
149
+ </body>
150
+
151
+ </html>```
152
+
153
+
154
+
67
- ###該当のソースコード
155
+ ###試したこと
156
+
157
+ 以下のように、textファイルを選択する場合はうまくいきます。
158
+
159
+ #!/usr/bin/env python
160
+
161
+ # coding: utf-8
162
+
163
+
164
+
165
+ import wave
166
+
167
+ from pylab import *
168
+
169
+ import sys
170
+
171
+ from pydub import AudioSegment
172
+
173
+ import cgi
174
+
175
+ import cgitb
176
+
177
+
178
+
179
+ cgitb.enable()
180
+
181
+
182
+
183
+ html_body = u"""
184
+
185
+ <html>
186
+
187
+ <head>
188
+
189
+ <meta http-equiv="content-type"content="text/html\n"></head>
190
+
191
+ <body>
192
+
193
+ <H1>%s</H1>
194
+
195
+ </body>
196
+
197
+ </html>"""
198
+
199
+
200
+
201
+ form = cgi.FieldStorage()
202
+
203
+ wf = form['file']
204
+
205
+ length = float(wf.getnframes()) / wf.getframerate() # 波形長さ(秒)
206
+
207
+ content = length
208
+
209
+
210
+
211
+
212
+
213
+ print ("Content-type: text/html;charset=utf-8\n")
214
+
215
+ print ((html_body % content))
216
+
217
+
218
+
219
+
68
220
 
69
221
  ```
70
222
 
71
- #!/usr/bin/env python
223
+
72
-
73
- # coding: utf-8
74
-
75
-
76
-
77
- import wave
78
-
79
- from pylab import *
80
-
81
- import sys
82
-
83
- from pydub import AudioSegment
84
-
85
- import cgi
86
-
87
- import cgitb
88
-
89
-
90
-
91
- cgitb.enable()
92
-
93
-
94
-
95
- html_body = u"""
96
-
97
- <html>
98
-
99
- <head>
100
-
101
- <meta http-equiv="content-type"content="text/html\n"></head>
102
-
103
- <body>
104
-
105
- %s
106
-
107
- </body>
108
-
109
- </html>"""
110
-
111
-
112
-
113
- form = cgi.FieldStorage()
114
-
115
- wf = form['file']
116
-
117
- length = float(wf.getnframes()) / wf.getframerate() # 波形長さ(秒)
118
-
119
- content = length
120
-
121
-
122
-
123
-
124
-
125
- print ("Content-type: text/html;charset=utf-8\n")
126
-
127
- print ((html_body % content))
128
-
129
-
130
-
131
-
132
-
133
- <<HTMLファイル>>
134
-
135
-
136
-
137
- <html>
138
-
139
- <head>
140
-
141
- <meta http-equiv="content-type" content="text/html;charset=utf-8"> </head>
142
-
143
- <body>
144
-
145
- <form action="/cgi-bin/test1.py" method="post" enctype="multipart/form-data"> 入力してください。<br /> 必須 :
146
-
147
- <input type="file" name="file" />
148
-
149
- <button>Send the file</button>
150
-
151
-
152
-
153
- </form>
154
-
155
- </body>
156
-
157
- </html>```
158
-
159
-
160
-
161
- ###試したこと
162
-
163
- 以下のように、textファイルを選択する場合はうまくいきます。
164
-
165
- #!/usr/bin/env python
166
-
167
- # coding: utf-8
168
-
169
-
170
-
171
- import wave
172
-
173
- from pylab import *
174
-
175
- import sys
176
-
177
- from pydub import AudioSegment
178
-
179
- import cgi
180
-
181
- import cgitb
182
-
183
-
184
-
185
- cgitb.enable()
186
-
187
-
188
-
189
- html_body = u"""
190
-
191
- <html>
192
-
193
- <head>
194
-
195
- <meta http-equiv="content-type"content="text/html\n"></head>
196
-
197
- <body>
198
-
199
- <H1>%s</H1>
200
-
201
- </body>
202
-
203
- </html>"""
204
-
205
-
206
-
207
- form = cgi.FieldStorage()
208
-
209
- wf = form['file']
210
-
211
- length = float(wf.getnframes()) / wf.getframerate() # 波形長さ(秒)
212
-
213
- content = length
214
-
215
-
216
-
217
-
218
-
219
- print ("Content-type: text/html;charset=utf-8\n")
220
-
221
- print ((html_body % content))
222
-
223
-
224
-
225
-
226
224
 
227
225
  ###補足情報(言語/FW/ツール等のバージョンなど)
228
226