teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

2020/10/01 06:03

投稿

tkgene
tkgene

スコア13

title CHANGED
@@ -1,1 +1,1 @@
1
- intとstrが今後する行の結合と操作
1
+ intとstrが混合する行の結合と操作
body CHANGED
File without changes

1

手違いがあり、異なるスクリプトを記載しておりました。もうしわけありません。実際のスクリプトに修正いたしました。

2020/10/01 06:03

投稿

tkgene
tkgene

スコア13

title CHANGED
File without changes
body CHANGED
@@ -9,7 +9,7 @@
9
9
  どなたかご教授お願いします。
10
10
  以下に試したスクリプトを乗せております。
11
11
 
12
- list'''
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
- data'''
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(list, 'r') as c:
47
+ with open('list_file.txt', 'r') as c:
51
48
  for line in c:
52
49
  if type(line) == str:
53
- specific_list.append(int(line.split()))
50
+ list.append(int(line.split()))
54
51
  else:
55
- specific_list.append(line.split())
52
+ list.append(line.split())
56
53
 
57
- with open(data, 'r') as f:
54
+ with open('data_file.txt', 'r') as f:
58
55
  for line in f:
59
56
  if type(line) == str:
60
- list_nonspec.append(int(line.split()))
57
+ data.append(int(line.split()))
61
58
  else:
62
- list_nonspec.append(line.split())
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-45-59245c3b6c10> in <module>
72
+ <ipython-input-48-553a02782dd4> in <module>
76
- 15 for line in c:
73
+ 9 for line in c:
77
- 16 if type(line) == str:
74
+ 10 if type(line) == str:
78
- ---> 17 specific_list.append(int(line.split()))
75
+ ---> 11 list.append(int(line.split()))
79
- 18 else:
76
+ 12 else:
80
- 19 specific_list.append(line.split())
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
  よろしくお願いします。