質問編集履歴
2
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
intとstrが
|
1
|
+
intとstrが混合する行の結合と操作
|
body
CHANGED
File without changes
|
1
手違いがあり、異なるスクリプトを記載しておりました。もうしわけありません。実際のスクリプトに修正いたしました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
どなたかご教授お願いします。
|
10
10
|
以下に試したスクリプトを乗せております。
|
11
11
|
|
12
|
-
|
12
|
+
list_file.txt'''
|
13
13
|
TTTTCTC 2219
|
14
14
|
TGCATGC 2143
|
15
15
|
GCATGCA 2140
|
@@ -18,7 +18,7 @@
|
|
18
18
|
TTTCTCT 1821
|
19
19
|
'''
|
20
20
|
|
21
|
-
|
21
|
+
data_file.txt'''
|
22
22
|
TTTTCTC 40
|
23
23
|
TGCATGC 21
|
24
24
|
GCATGCA 20
|
@@ -41,25 +41,22 @@
|
|
41
41
|
|
42
42
|
試したスクリプト
|
43
43
|
```
|
44
|
-
#!/usr/bin/env python3
|
45
|
-
# coding: UTF-8
|
46
|
-
|
47
|
-
list= []
|
44
|
+
list = []
|
48
45
|
data = []
|
49
46
|
|
50
|
-
with open(
|
47
|
+
with open('list_file.txt', 'r') as c:
|
51
48
|
for line in c:
|
52
49
|
if type(line) == str:
|
53
|
-
|
50
|
+
list.append(int(line.split()))
|
54
51
|
else:
|
55
|
-
|
52
|
+
list.append(line.split())
|
56
53
|
|
57
|
-
with open(
|
54
|
+
with open('data_file.txt', 'r') as f:
|
58
55
|
for line in f:
|
59
56
|
if type(line) == str:
|
60
|
-
|
57
|
+
data.append(int(line.split()))
|
61
58
|
else:
|
62
|
-
|
59
|
+
data.append(line.split())
|
63
60
|
|
64
61
|
for c in tss_list:
|
65
62
|
for f in gene_list:
|
@@ -68,18 +65,18 @@
|
|
68
65
|
print(c[0],"\t",c[1],"\t",c[1] - c[2],)
|
69
66
|
elif c[0] in f[0]:
|
70
67
|
print(c[0],"\t",c[1],"\t", 0 )
|
71
|
-
|
72
68
|
```
|
73
69
|
エラー
|
70
|
+
---------------------------------------------------------------------------
|
74
71
|
TypeError Traceback (most recent call last)
|
75
|
-
<ipython-input-
|
72
|
+
<ipython-input-48-553a02782dd4> in <module>
|
76
|
-
|
73
|
+
9 for line in c:
|
77
|
-
|
74
|
+
10 if type(line) == str:
|
78
|
-
--->
|
75
|
+
---> 11 list.append(int(line.split()))
|
79
|
-
|
76
|
+
12 else:
|
80
|
-
|
77
|
+
13 list.append(line.split())
|
81
78
|
|
82
|
-
TypeError: int() argument must be a string
|
79
|
+
TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'
|
83
80
|
|
84
81
|
これはそもそもappendを使うのが間違っているのでしょうか。
|
85
82
|
よろしくお願いします。
|