2016-11-09 7 views
0

私はIDLEを使用していますが、私が書いているスクリプトでは#を入力できる必要があります。 IDLEを使用してコードを実行すると、#はコメントとして書かれたときと同じように、入力としても赤色で表示されます。どのようにこれを回避することができますか?私は、さまざまなエンコーディングなどにあまり熟練していないので、IDLEで動作させる方法を探しています。IDLEを使用して "#"を入力したい

+0

文字列リテラルに入れてみましたか? –

+0

「#」と書いていますか?あなたはstr(#)を意味しますか? – user1036197

答えて

1

入力したい文字列を入力するだけです。 「回避策」は必要ありません。 bugという小文字ですが、IDLEは構文応答を入力応答に適用しますが、注意散漫以外は無害です。

>>> s = input(': ') 
: #@%!#  
>>> s 
'#@%!#' 
+0

ありがとう、色は私がそれが文字列として受け入れられないと思って気を散らしていた。あなたが言うように、それはうまく動作します。どうもありがとうございます。 – user1036197

1

あなたはどのバージョンのPython IDLEを使用していますか?以下のコードはPythonの3.5.2 IDLE

>>> # declare the user input and assign a placeholder variable 
>>> user_input = ' ' 
>>> while user_input != 'end': 
    # get user input until the user input the word end 
    user_input = input('>> ') 
    # as long as the word end is not entered print the input results 
    if user_input != 'end': 
     print(user_input) 

に書かれた次の出力を生成します。助け

>> # 
# 
>> ## 
## 
>> What is the # 
What is the # 
>> What format would you like the time in ##:##:## 
What format would you like the time in ##:##:## 
>> Print some ###### 
Print some ###### 
>> end 
>>> 

希望。

関連する問題