質問編集履歴

7

文法の修正

2023/02/06 05:22

投稿

Apollo
Apollo

スコア1

test CHANGED
File without changes
test CHANGED
@@ -63,7 +63,7 @@
63
63
  また、下記のようなstr関数とinput関数の組み合わせの場合はエラーは発生しないのですが、正常な実行結果が表示されません。
64
64
 
65
65
  ```python
66
- a = str(input("字を入力"))
66
+ a = str(input("字を入力"))
67
67
  ```
68
68
 
69
69
  実行結果:
@@ -71,7 +71,7 @@
71
71
  python -u "/Users/Ituki0406/Desktop/Programing/MyPython/test.py"
72
72
  conda activate base
73
73
  (base) Ituki0406@MacBook-Pro-3 Programing % python -u "/Users/Ituki0406/Desktop/Programing/MyPython/test.py"
74
- 字を入力conda activate base
74
+ 字を入力conda activate base
75
75
  ```
76
76
 
77
77
  どうぞよろしくお願いいたします。

6

追記の削除

2023/02/06 05:08

投稿

Apollo
Apollo

スコア1

test CHANGED
File without changes
test CHANGED
@@ -75,17 +75,3 @@
75
75
  ```
76
76
 
77
77
  どうぞよろしくお願いいたします。
78
-
79
-
80
-
81
- 追記:
82
- ```
83
- cat /Users/Ituki0406/.zprofile
84
- ```
85
- ↑を実行した結果は下記になります。
86
-
87
- ```
88
- # Set PATH, MANPATH, etc., for Homebrew. eval "$(/opt/homebrew/bin/brew shellenv)"
89
- # Set PATH, MANPATH, etc., for Homebrew. eval "$(/opt/homebrew/bin/brew shellenv)"
90
- # Set PATH, MANPATH, etc., for Homebrew. eval "$(/opt/homebrew/bin/brew shellenv)"
91
- ```

5

文法の修正

2023/02/04 09:23

投稿

Apollo
Apollo

スコア1

test CHANGED
File without changes
test CHANGED
@@ -52,16 +52,31 @@
52
52
 
53
53
  同様のプログラムを何も修正せずにただ再度実行した際は、なぜか正常に機能します。
54
54
 
55
- 加えて、上記のエラーは
55
+ エラーが発生する条件下記のようにint関数とinput関数の組み合わせた時と推測しています。
56
56
 
57
- ```
57
+ ```python
58
- print("hello")
58
+ a = int(input("数字を入力"))
59
59
  ```
60
60
 
61
+ ↑のようなint関数とinput関数を組み合わせて使用した時に限り、エラーが発生してしまいます。(input関数やint関数を単体で使用した際はエラーが発生しません)
62
+
63
+ また、下記のようなstr関数とinput関数の組み合わせの場合はエラーは発生しないのですが、正常な実行結果が表示されません。
64
+
61
- などでは出ず、
65
+ ```python
66
+ a = str(input("数字を入力"))
67
+ ```
68
+
69
+ 実行結果:
70
+ ```python
71
+ python -u "/Users/Ituki0406/Desktop/Programing/MyPython/test.py"
62
- 少し複雑なプログラムでのみ発生します。
72
+ conda activate base
73
+ (base) Ituki0406@MacBook-Pro-3 Programing % python -u "/Users/Ituki0406/Desktop/Programing/MyPython/test.py"
74
+ 数字を入力conda activate base
75
+ ```
63
76
 
64
77
  どうぞよろしくお願いいたします。
78
+
79
+
65
80
 
66
81
  追記:
67
82
  ```

4

文法の修正

2023/02/04 01:11

投稿

Apollo
Apollo

スコア1

test CHANGED
File without changes
test CHANGED
@@ -1,13 +1,11 @@
1
1
  現在MacBookでVSCodeを使用し、Pythonのプログラミングを勉強中です。
2
2
  そこで、試しにいくつかコーディングした際に、下記のようなエラーが出てしまうことがあります。
3
3
 
4
- ```
4
+ ```python
5
- python -u "/Users/Ituki0406/Desktop/Programing/MyP/Users/Ituki0406/.zprofile:2: no such file or directory: /opt/homebrew/bin/brew
5
+ python -u "/Users/Ituki0406/Desktop/Programing/MyPython/calculation.py"
6
- ython/calculation.py"
7
- /Users/Ituki0406/.zprofile:4: no such file or directory: /opt/homebrew/bin/brew
8
- /Users/Ituki0406/.zprofile:6: no such file or directory: /opt/homebrew/bin/brew
9
6
  conda activate base
10
- (base) Ituki0406@MacBook-Pro-3 Programing % python -u "/Users/Ituki0406/Desktop/Programing/MyPython/calculation.py"
7
+ (base) Ituki0406@MacBook-Pro-3 Programing % python -u "/Users/Ituki0406/Desktop/Programing/MyPython/calcul
8
+ ation.py"
11
9
  計算機
12
10
  1.足し算 2.引き算 3.掛け算 4.割り算 5.文字数計算 >>conda activate base
13
11
  Traceback (most recent call last):

3

追記

2023/02/04 01:07

投稿

Apollo
Apollo

スコア1

test CHANGED
File without changes
test CHANGED
@@ -65,3 +65,14 @@
65
65
 
66
66
  どうぞよろしくお願いいたします。
67
67
 
68
+ 追記:
69
+ ```
70
+ cat /Users/Ituki0406/.zprofile
71
+ ```
72
+ ↑を実行した結果は下記になります。
73
+
74
+ ```
75
+ # Set PATH, MANPATH, etc., for Homebrew. eval "$(/opt/homebrew/bin/brew shellenv)"
76
+ # Set PATH, MANPATH, etc., for Homebrew. eval "$(/opt/homebrew/bin/brew shellenv)"
77
+ # Set PATH, MANPATH, etc., for Homebrew. eval "$(/opt/homebrew/bin/brew shellenv)"
78
+ ```

2

新たな質問を追加

2023/02/04 01:05

投稿

Apollo
Apollo

スコア1

test CHANGED
@@ -1 +1 @@
1
- no such file or directoryのPythonエラーに関しまして
1
+ PythonのValueErrorに関しまして
test CHANGED
@@ -1,6 +1,7 @@
1
1
  現在MacBookでVSCodeを使用し、Pythonのプログラミングを勉強中です。
2
2
  そこで、試しにいくつかコーディングした際に、下記のようなエラーが出てしまうことがあります。
3
3
 
4
+ ```
4
5
  python -u "/Users/Ituki0406/Desktop/Programing/MyP/Users/Ituki0406/.zprofile:2: no such file or directory: /opt/homebrew/bin/brew
5
6
  ython/calculation.py"
6
7
  /Users/Ituki0406/.zprofile:4: no such file or directory: /opt/homebrew/bin/brew
@@ -13,8 +14,11 @@
13
14
  File "/Users/Ituki0406/Desktop/Programing/MyPython/calculation.py", line 2, in <module>
14
15
  method = int(input("1.足し算 2.引き算 3.掛け算 4.割り算 5.文字数計算 >>"))
15
16
  ValueError: invalid literal for int() with base 10: 'conda activate base'
17
+ ```
16
18
 
17
19
  記入したコードは↓です。
20
+
21
+ ```python
18
22
  print("計算機")
19
23
  method = int(input("1.足し算 2.引き算 3.掛け算 4.割り算 5.文字数計算 >>"))
20
24
 
@@ -46,26 +50,18 @@
46
50
  print("正しく数字を入力してください")
47
51
 
48
52
  print("THE END")
53
+ ```
49
54
 
50
55
  同様のプログラムを何も修正せずにただ再度実行した際は、なぜか正常に機能します。
51
56
 
52
- 推測ではありますが↓が原因ではないかと考えています。
53
- python -u "/Users/Ituki0406/Desktop/Programing/MyP/Users/Ituki0406/.zprofile:2: no such file or directory: /opt/homebrew/bin/brew
54
- ython/calculation.py"
55
- /Users/Ituki0406/.zprofile:4: no such file or directory: /opt/homebrew/bin/brew
56
- /Users/Ituki0406/.zprofile:6: no such file or directory: /opt/homebrew/bin/brew
57
- conda activate base
57
+ 加えて、上記のエラーは
58
58
 
59
+ ```
59
- こちらを消す方法はありますでしょうか?
60
+ print("hello")
60
- 尚、homebrewは一度インストールしたのですが、アンインストール済みです。
61
+ ```
61
62
 
62
- 加えて、上記のエラーはprint("hello")などでは出ず、
63
+ などでは出ず、
63
64
  少し複雑なプログラムでのみ発生します。
64
65
 
65
66
  どうぞよろしくお願いいたします。
66
67
 
67
- 追記:
68
- cat /Users/Ituki0406/.zprofile を実行した結果は下記になります↓
69
-
70
- # Set PATH, MANPATH, etc., for Homebrew. eval "$(/opt/homebrew/bin/brew shellenv)" # Set PATH, MANPATH, etc., for Homebrew. eval "$(/opt/homebrew/bin/brew shellenv)" # Set PATH, MANPATH, etc., for Homebrew. eval "$(/opt/homebrew/bin/brew shellenv)"
71
-

1

追記

2023/02/03 10:51

投稿

Apollo
Apollo

スコア1

test CHANGED
File without changes
test CHANGED
@@ -64,3 +64,8 @@
64
64
 
65
65
  どうぞよろしくお願いいたします。
66
66
 
67
+ 追記:
68
+ cat /Users/Ituki0406/.zprofile を実行した結果は下記になります↓
69
+
70
+ # Set PATH, MANPATH, etc., for Homebrew. eval "$(/opt/homebrew/bin/brew shellenv)" # Set PATH, MANPATH, etc., for Homebrew. eval "$(/opt/homebrew/bin/brew shellenv)" # Set PATH, MANPATH, etc., for Homebrew. eval "$(/opt/homebrew/bin/brew shellenv)"
71
+