質問編集履歴
20
書式
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
PythonのCGIのwavファイルの読み込みに関してです。
|
body
CHANGED
File without changes
|
19
書式
title
CHANGED
File without changes
|
body
CHANGED
@@ -30,8 +30,8 @@
|
|
30
30
|
with_traceback = <built-in method with_traceback of AttributeError object>
|
31
31
|
```
|
32
32
|
###該当のソースコード
|
33
|
-
```
|
34
|
-
python
|
33
|
+
```python
|
34
|
+
|
35
35
|
import wave
|
36
36
|
from pylab import *
|
37
37
|
import sys
|
@@ -79,7 +79,6 @@
|
|
79
79
|
```
|
80
80
|
import cgi
|
81
81
|
import sys
|
82
|
-
import datetime
|
83
82
|
import cgitb
|
84
83
|
|
85
84
|
cgitb.enable()
|
18
書式
title
CHANGED
File without changes
|
body
CHANGED
@@ -89,9 +89,7 @@
|
|
89
89
|
<head>
|
90
90
|
<meta http-equiv="content-type"content="text/html\n"></head>
|
91
91
|
<body>
|
92
|
-
<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>
|
93
|
-
|
94
|
-
|
92
|
+
%s
|
95
93
|
</body>
|
96
94
|
</html>"""
|
97
95
|
|
17
書式
title
CHANGED
File without changes
|
body
CHANGED
@@ -74,12 +74,8 @@
|
|
74
74
|
</body>
|
75
75
|
</html>
|
76
76
|
```
|
77
|
-
```
|
78
|
-
|
79
|
-
|
80
|
-
|
81
77
|
###試したこと
|
82
|
-
以下のように、textファイルを選択する場合はうまくいきます。
|
78
|
+
###以下のように、textファイルを選択する場合はうまくいきます。
|
83
79
|
```
|
84
80
|
import cgi
|
85
81
|
import sys
|
16
書式
title
CHANGED
File without changes
|
body
CHANGED
@@ -29,6 +29,7 @@
|
|
29
29
|
args = ('getnframes',)
|
30
30
|
with_traceback = <built-in method with_traceback of AttributeError object>
|
31
31
|
```
|
32
|
+
###該当のソースコード
|
32
33
|
```
|
33
34
|
python
|
34
35
|
import wave
|
@@ -79,7 +80,7 @@
|
|
79
80
|
|
80
81
|
###試したこと
|
81
82
|
以下のように、textファイルを選択する場合はうまくいきます。
|
82
|
-
|
83
|
+
```
|
83
84
|
import cgi
|
84
85
|
import sys
|
85
86
|
import datetime
|
@@ -113,6 +114,6 @@
|
|
113
114
|
print ("Content-type: text/html;charset=utf-8\n")
|
114
115
|
print ((html_body % content))
|
115
116
|
|
116
|
-
|
117
|
+
```
|
117
118
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
118
119
|
より詳細な情報
|
15
書式
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,8 +7,7 @@
|
|
7
7
|
##発生している問題・エラーメッセージ
|
8
8
|
|
9
9
|
|
10
|
-
``
|
10
|
+
```
|
11
|
-
<<エラー文>>
|
12
11
|
|
13
12
|
A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.
|
14
13
|
|
@@ -30,6 +29,7 @@
|
|
30
29
|
args = ('getnframes',)
|
31
30
|
with_traceback = <built-in method with_traceback of AttributeError object>
|
32
31
|
```
|
32
|
+
```
|
33
33
|
python
|
34
34
|
import wave
|
35
35
|
from pylab import *
|
14
書式
title
CHANGED
File without changes
|
body
CHANGED
@@ -31,10 +31,6 @@
|
|
31
31
|
with_traceback = <built-in method with_traceback of AttributeError object>
|
32
32
|
```
|
33
33
|
python
|
34
|
-
|
35
|
-
```
|
36
|
-
###以下のようにコードを書きました。
|
37
|
-
|
38
34
|
import wave
|
39
35
|
from pylab import *
|
40
36
|
import sys
|
@@ -75,8 +71,12 @@
|
|
75
71
|
|
76
72
|
</form>
|
77
73
|
</body>
|
78
|
-
</html>
|
74
|
+
</html>
|
79
75
|
```
|
76
|
+
```
|
77
|
+
|
78
|
+
|
79
|
+
|
80
80
|
###試したこと
|
81
81
|
以下のように、textファイルを選択する場合はうまくいきます。
|
82
82
|
|
13
書式
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
##
|
2
|
-
python初心者(python3.5)です。
|
2
|
+
python初心者(python3.5)です。CGIの勉強をしていましてwavファイルの読み込みの方法がどうしてもわかりません。どなたかpythonに詳しい方、ご教示をお願いいたします。
|
3
3
|
例えば、wavファイルを選択して、そのwavファイルの長さを返したい場合、以下のようにコードを書いたのですが、
|
4
4
|
実装中に以下のエラーメッセージが発生しました。
|
5
5
|
|
12
書式
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
Python3 CGIのwavファイルの読み込みに関してです。
|
body
CHANGED
File without changes
|
11
書式
title
CHANGED
File without changes
|
body
CHANGED
@@ -30,7 +30,7 @@
|
|
30
30
|
args = ('getnframes',)
|
31
31
|
with_traceback = <built-in method with_traceback of AttributeError object>
|
32
32
|
```
|
33
|
-
python
|
33
|
+
python
|
34
34
|
|
35
35
|
```
|
36
36
|
###以下のようにコードを書きました。
|
10
書式
title
CHANGED
File without changes
|
body
CHANGED
@@ -30,7 +30,8 @@
|
|
30
30
|
args = ('getnframes',)
|
31
31
|
with_traceback = <built-in method with_traceback of AttributeError object>
|
32
32
|
```
|
33
|
-
|
33
|
+
python<改行>プログラムの中身・・・<改行>
|
34
|
+
|
34
35
|
```
|
35
36
|
###以下のようにコードを書きました。
|
36
37
|
|
9
title
CHANGED
File without changes
|
body
CHANGED
File without changes
|
8
書式
title
CHANGED
File without changes
|
body
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
```
|
33
33
|
python3
|
34
34
|
```
|
35
|
-
###以下のようにコード
|
35
|
+
###以下のようにコードを書きました。
|
36
36
|
|
37
37
|
import wave
|
38
38
|
from pylab import *
|
7
書式
title
CHANGED
File without changes
|
body
CHANGED
@@ -101,7 +101,7 @@
|
|
101
101
|
fileitem = form["file"]
|
102
102
|
kek =[]
|
103
103
|
if fileitem.file:
|
104
|
-
|
104
|
+
|
105
105
|
linecount = 0
|
106
106
|
while True:
|
107
107
|
line = fileitem.file.readline()
|
6
書式
title
CHANGED
File without changes
|
body
CHANGED
@@ -32,11 +32,8 @@
|
|
32
32
|
```
|
33
33
|
python3
|
34
34
|
```
|
35
|
-
|
35
|
+
###以下のようにコード以下のようにを書きました。
|
36
36
|
|
37
|
-
#!/usr/bin/env python
|
38
|
-
# coding: utf-8
|
39
|
-
|
40
37
|
import wave
|
41
38
|
from pylab import *
|
42
39
|
import sys
|
@@ -81,8 +78,7 @@
|
|
81
78
|
```
|
82
79
|
###試したこと
|
83
80
|
以下のように、textファイルを選択する場合はうまくいきます。
|
84
|
-
|
81
|
+
|
85
|
-
# coding: utf-8
|
86
82
|
import cgi
|
87
83
|
import sys
|
88
84
|
import datetime
|
5
書式
title
CHANGED
File without changes
|
body
CHANGED
@@ -30,8 +30,10 @@
|
|
30
30
|
args = ('getnframes',)
|
31
31
|
with_traceback = <built-in method with_traceback of AttributeError object>
|
32
32
|
```
|
33
|
-
|
33
|
+
python3
|
34
34
|
```
|
35
|
+
試したコード
|
36
|
+
|
35
37
|
#!/usr/bin/env python
|
36
38
|
# coding: utf-8
|
37
39
|
|
4
書式
title
CHANGED
File without changes
|
body
CHANGED
@@ -30,8 +30,7 @@
|
|
30
30
|
args = ('getnframes',)
|
31
31
|
with_traceback = <built-in method with_traceback of AttributeError object>
|
32
32
|
```
|
33
|
-
``````
|
33
|
+
``````Python3
|
34
|
-
python3
|
35
34
|
```
|
36
35
|
#!/usr/bin/env python
|
37
36
|
# coding: utf-8
|
3
書式
title
CHANGED
File without changes
|
body
CHANGED
@@ -30,6 +30,9 @@
|
|
30
30
|
args = ('getnframes',)
|
31
31
|
with_traceback = <built-in method with_traceback of AttributeError object>
|
32
32
|
```
|
33
|
+
``````ここに言語を入力
|
34
|
+
python3
|
35
|
+
```
|
33
36
|
#!/usr/bin/env python
|
34
37
|
# coding: utf-8
|
35
38
|
|
@@ -74,7 +77,7 @@
|
|
74
77
|
</form>
|
75
78
|
</body>
|
76
79
|
</html>```
|
77
|
-
|
80
|
+
```
|
78
81
|
###試したこと
|
79
82
|
以下のように、textファイルを選択する場合はうまくいきます。
|
80
83
|
#!/usr/bin/env python
|
2
誤字
title
CHANGED
File without changes
|
body
CHANGED
@@ -79,12 +79,9 @@
|
|
79
79
|
以下のように、textファイルを選択する場合はうまくいきます。
|
80
80
|
#!/usr/bin/env python
|
81
81
|
# coding: utf-8
|
82
|
-
|
83
|
-
import
|
82
|
+
import cgi
|
84
|
-
from pylab import *
|
85
83
|
import sys
|
86
|
-
from pydub import AudioSegment
|
87
|
-
import
|
84
|
+
import datetime
|
88
85
|
import cgitb
|
89
86
|
|
90
87
|
cgitb.enable()
|
@@ -94,21 +91,27 @@
|
|
94
91
|
<head>
|
95
92
|
<meta http-equiv="content-type"content="text/html\n"></head>
|
96
93
|
<body>
|
94
|
+
<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>
|
95
|
+
|
97
96
|
<H1>%s</H1>
|
98
97
|
</body>
|
99
98
|
</html>"""
|
100
99
|
|
101
|
-
form
|
100
|
+
form=cgi.FieldStorage()
|
102
|
-
|
101
|
+
fileitem = form["file"]
|
102
|
+
kek =[]
|
103
|
+
if fileitem.file:
|
104
|
+
# It's an uploaded file; count lines
|
105
|
+
linecount = 0
|
106
|
+
while True:
|
103
|
-
|
107
|
+
line = fileitem.file.readline()
|
108
|
+
kek.append(line)
|
109
|
+
if not line: break
|
110
|
+
linecount = linecount + 1
|
104
|
-
content =
|
111
|
+
content = kek
|
105
|
-
|
106
|
-
|
107
112
|
print ("Content-type: text/html;charset=utf-8\n")
|
108
113
|
print ((html_body % content))
|
109
114
|
|
110
|
-
|
111
|
-
```
|
112
115
|
|
113
116
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
114
117
|
より詳細な情報
|
1
書式
title
CHANGED
File without changes
|
body
CHANGED
@@ -30,9 +30,6 @@
|
|
30
30
|
args = ('getnframes',)
|
31
31
|
with_traceback = <built-in method with_traceback of AttributeError object>
|
32
32
|
```
|
33
|
-
|
34
|
-
###該当のソースコード
|
35
|
-
```
|
36
33
|
#!/usr/bin/env python
|
37
34
|
# coding: utf-8
|
38
35
|
|
@@ -111,5 +108,7 @@
|
|
111
108
|
print ((html_body % content))
|
112
109
|
|
113
110
|
|
111
|
+
```
|
112
|
+
|
114
113
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
115
114
|
より詳細な情報
|